<pre><code>package main
import (
"fmt"
)
func main() {
var arr []int
setArr(&arr)
fmt.Printf("point behand: %p,value behand: %v \n", arr, arr)
}
func setArr(arr *[]int) {
arr1 := &[]int{1, 2}
arr = arr1
fmt.Printf("point before: %p,value before: %v \n", arr, arr)
}
输出:
point before: 0xc42000a260,value before: &[1 2]
point behand: 0x0,value behand: []</code></pre>
有疑问加站长微信联系(非本文作者)