```````
testList := []uint16{1, 2, 3, 4}
myTest := testList //1.mytest 和 testList指向同一段
myTest = append(myTest, 9) //分离指向,所以在设计的时候最好给一个cap,不需要频繁的开辟内存
fmt.Println(testList)
```````
```go
testList := []uint16{1, 2, 3, 4}
fmt.Printf("%p\n", &testList)
myTest := testList //1.mytest 和 testList指向同一段
testList[0] = 10
fmt.Printf("%p\n", &myTest)
myTest = append(myTest, 9) //分离指向,所以在设计的时候最好给一个cap,不需要频繁的开辟内存
fmt.Printf("%p\n", &myTest)
myTest[0] = 9
fmt.Println(testList)
fmt.Println(myTest)
0xc21000a020
0xc21000a060
0xc21000a060
[10 2 3 4]
[9 2 3 4 9]
```
如果你还是看不懂, 放弃吧, 你不适合golang, 还是去学java更合适.
#4
更多评论
<a href="/user/focusonline" title="@focusonline">@focusonline</a> 那请问range多重map[]map[]val呢,不注意么?
#2