This is a creation in Article, where the information may have evolved or changed.
Golang uses array to represent fixed-size arrays, and slice to represent dynamic arrays.
Package Mainimport "FMT" Func Main () {var a = [5]int{2,3,5,7,11}fmt. Printf ("type of array:%t\n", a) fmt. Printf ("Address of Array:%p\n", &a) fmt. Printf ("Address of arrar[0]:%p\n", &a[0]) s: = A[:]fmt. Printf ("slice =%v, Len =%d, Cap =%d\n", S, Len (s), Cap (s)) fmt. Printf ("Address of Slice:%p\n", &s) fmt. Printf ("Address of slice[0]:%p\n", &s[0]) s = append (s), FMT. Printf ("slice =%v, Len =%d, Cap =%d\n", S, Len (s), Cap (s)) fmt. Printf ("Address of Slice:%p\n", &s) fmt. Printf ("Address of slice[0]:%p\n", &s[0])}
The output is as follows:
Type of array: [5]int
Address of array:0xc420014150
Address of arrar[0]: 0xc420014150
Slice = [2 3 5 7], Len = 5, Cap = 5
Address of slice:0xc42000a060
Address of slice[0]: 0xc420014150
Slice = [2 3 5 7], Len = 6, Cap = 10
Address of slice:0xc42000a060
Address of slice[0]: 0xc42001c0f0
Resources:
Slices:usage and Internals
https://golang.org/pkg/builtin/#append