func printArray(my_arr []int){ // ERROR: cannot use arr (type [8]int) as type []int in argument to printArray
fmt.Println(len(my_arr))
}
func main(){
arr := [...]int{17,-22,15,20,33,25,22,19}
printArray(arr)
}
Run Code Online (Sandbox Code Playgroud)
与在 C++ 中一样,我们使用引用传递在函数中传递数组。我们可以在 Go 中做同样的事情吗?