News for hackers. Stuff that matters.
Re:Go: A Surprising Edge Case Concerning Append and Slice Al... by tshadwell on Saturday May 16, 2015 @09:07AM (#9555947)
Your understanding is incorrect, too. append() only returns a new slice when "the capacity of s is not large enough to fit the additional values", in which case "append allocates a new, sufficiently large underlying array that fits both the existing slice elements and the additional values. Otherwise, append re-uses the underlying array."

[-] http://golang.org/ref/spec#Appending_and_copying_slices

Re:Go: A Surprising Edge Case Concerning Append and Slice Al... by skj on Saturday May 16, 2015 @09:27AM (#9556005)
No, nicksardo's understanding was quite correct. Slices are values, and it is impossible to return the same one, because value semantics don't work like that.

The slice returned only points to a new array when the capacity is not large enough to fit additional values.

Re:Go: A Surprising Edge Case Concerning Append and Slice Al... by a-nom-a-ly on Saturday May 16, 2015 @09:23AM (#9555997)
You seem to be confusing `array` with `slice`. AFAIK, append always returns a new slice. How could it not, when everything is copy/pass by value? A slice is essentially a struct with fields for len, cap and a pointer to an array.