This is a creation in Article, where the information may have evolved or changed.
1 map and slice itself are value passes. But if you modify what they point to, it affects the outside of the function.
2 copy of map and slice, they are pointing and manipulating the same object.
package mainimport ( "fmt")func test2(m map[string]int) { m["aaa"] = 10}func test4(m map[string]int) { m = make(map[string]int)}func test3(a []int) { a = append(a, 10)}func test_mod_slice_content(a []int) { a[0] = 10000}func test() { a := make(map[string]int) fmt.Printf("%v\n", a) test2(a) fmt.Printf("%v\n", a) aa := a aa["b"] = 20 fmt.Printf("%v\n", a) fmt.Printf("%v\n", aa) test4(aa) fmt.Printf("%v\n", aa) b := make([]int, 0) fmt.Printf("%v\n", b) test3(b) fmt.Printf("%v\n", b) b = append(b, 20) fmt.Printf("%v\n", b) test_mod_slice_content(b) fmt.Printf("%v\n", b)}func main() { test()}
Output:
map[]map[aaa:10]map[b:20 aaa:10]map[aaa:10 b:20]map[aaa:10 b:20][][][20][10000]