This is a creation in Article, where the information may have evolved or changed.
Slicing and data
When learning Golang, when a slice is generated from an array, the slice actually has a pointer to that array, so the operations on the slices and arrays affect each other.
Curious is the slice is longer, when the slice exceeds the original array length, will still keep that pointer, or there is a more advanced way, today tried, it is more disappointing, to perform append operation on the slice, when the capacity of the slice is exceeded, go will assign a new array to the slice, The two parted from each other.
The append operation allocates a new array when the underlying array of slices is insufficient, so it is best to calculate the amount of space to use if you are using slices.
It may be that the immutable variable effect of functional programming has recently been felt, and it is always a bit dangerous to share the same piece of memory with an array.
There are a number of replication operations in functional languages, in performance and memory considerations, and their collection implementations should be different from normal collections and have time to see their implementations.
New and make
Go has the data structure creation functions:new and make. The distinction is a common early point of confusion but seems to quickly become. The basic distinction is this new (T) returns a *t, a pointer that Go programs can dereference implicitly (the Black Pointe RS in the diagrams), while make (T, args) returns an ordinary T, not a pointer. Often that T have inside it some implicit pointers (the gray pointers in the diagrams). New returns a pointer to zeroed memory, while make returns a complex structure.
Simply put, new returns a pointer, make returns a value, but this value usually contains pointers at the bottom.
The above English part is transferred from Http://research.swtch.com/godata