Series
The Data Structures Series
One structure per post, implemented and tested in Go: what it is, what it costs in time, space and the constant factors Go imposes, when to reach for it, when to reach for something else, how to write it, and how to test it properly. Part of Under the Hood.
What a Go Slice Actually Is
A Go slice is three words: a pointer to a backing array, a length and a capacity. Append writes into spare capacity when there is some and reallocates when there is not, so whether your caller sees the write depends on a number the caller cannot see. That is where a lot of real Go bugs come from, and it is a consequence of the header being a value while the array is shared.
Coming soon