array是值传递

s := [5] int{1,2,4}
l := s
l[0] = 10
fmt.Println(s)
fmt.Println(l)

打印结果

[1 2 4 0 0]
[10 2 4 0 0]

和python不同

s = [1, 2, 3]
l = s
l[0] = 2

print(l, s)

打印结果

[2, 2, 3] [2, 2, 3]

你可能感兴趣的:(array是值传递)