package main import ( "fmt" ) func main() { var arr [3]int fmt.Println(len(arr), cap(arr)) var arr1 []int arr1 = append(arr1, 2) fmt.Println(len(arr1), cap(arr1)) var arr3 = make([]int, 0) fmt.Println(len(arr3), cap(arr3)) arr3 = append(arr3, 1, 2, 3, 3, 4, 2, 5, 5, 6, 6, 3) //子切片 fmt.Println(arr3[0:1]) } //多参数返回 func add(num, num2 int) (string, int) { return "num+num2=", num + num2 } //不限数量参数传入 func multiParams(s ...int) { fmt.Println(s) } GOROOT=/usr/local/go #gosetup GOPATH=/Users/langhuaili/go #gosetup /usr/local/go/bin/go build -o /private/var/folders/1v/tcj55mj165vgcglnqkrkgtk40000gn/T/GoLand/___go_build_geekstudy geekstudy #gosetup /private/var/folders/1v/tcj55mj165vgcglnqkrkgtk40000gn/T/GoLand/___go_build_geekstudy 3 3 1 1 0 0 [1]