分类:golang
golang中允许对值为nil的slice添加元素packagemainfuncmain(){vars[]ints=append(s,1)}运行成功~补充:golangslice详解一、数组切片的使用funcmain(){//1.基于数组创建数组切片vararray[10]int=[10]int{1,2,3,4,5,6,7,8,9,10}varslice=array[1:7]//array[startIndex:endIndex]不包含endIndex//2.直接创建数组切片slice2:=make([]int,5,10)//3.直接创建并初始化数组切片slice3:=...
继续阅读 >
添加水印示例添加main文件“watermark/main.go”packagemainimport("fmt""watermark/textwatermark")funcmain(){SavePath:="./kaf"str:=textwatermark.FontInfo{18,"努力向上",textwatermark.TopLeft,20,20,255,255,0,255}arr:=make([]textwatermark.FontInfo,0)arr=append(arr,str)str2:=textwatermark.FontInfo{Size:24,Message:"努力向上,涨工资",Position:textwatermark.TopLeft,Dx:2...
继续阅读 >
2021
05-25