Slice
Difference between slices and arrays Arrays, after declared of some size, cannot be resized, but slices can be resized. Slices are reference-types while arrays are value-type.
An example :
func testArray(x [2]int) { fmt.Printf("func Array : %p, %v\n", &x, x) } func main() { arrayA := [2]int{100, 200} var arrayB [2]int arrayB = arrayA fmt.Printf("ArrayA : %p, %v\n", &arrayA, arrayA) fmt.Printf("ArrayB : %p, %v\n", &arrayB, arrayB) testArray(arrayA) } ArrayA : 0xc0000200c0, [100 200] ArrayB : 0xc0000200d0, [100 200] func Array : 0xc000020110, [100 200] The three memory addresses (0xc0000200c0,0xc0000200d0,0xc000020110) are all different, which verifies that array assignment and function parameter transfer in Go are all copied by value.