func Test(strSlice ...string) {
for i, s := range strSlice {
log.Println(i, s)
}
}
在函数内部,strSlice是一个 []string 类型
strSlice := []string{"a", "b", "c"}
Test(strSlice...)
Test函数只能接收 多个string类型的参数
var intSlice []int
appendSlice := []int{1, 2, 3}
intSlice = append(intSlice, appendSlice...)
append可以把string打散成byte
var byteSlice []byte
byteSlice = append(byteSlice, "abc"..)
array := [...]int{1, 2, 3}
go test ./...
原文:https://www.cnblogs.com/wayland3/p/12179929.html