//接受可变长参数 func arg(args ...string){ for i,v:=range args{ fmt.Printf("index %d, value %v \n",i,v) } } func main(){ temp:=[]string{"111","4555"} arg(temp...) //解包切片 arg("222","3333","6666")//多个不确定数量的参数 }
//输出
index 0, value 111
index 1, value 4555
index 0, value 222
index 1, value 3333
index 2, value 6666
标签:...,index,value,用法,111,arg,Go,4555 From: https://www.cnblogs.com/zxqblogrecord/p/16648078.html