

Reduce allocation in Go code - percept
http://methane.github.io/2015/02/reduce-allocation-in-go-code/

======
tptacek
FWIW: If you're working with strings gradually built out of other strings, the
Golang idiom is bytes.Buffer, to which you write strings as if to a file. It's
the Golang equivalent of building an array of strings in Python and join()ing
it.

~~~
kevin_thibedeau
And how does this work when Unicode combining characters come into play?

~~~
tptacek
I'm not sure I see the problem. You can safely write a utf-8 string to a
bytes.Buffer.

------
Animats
Go does many small allocations behind the scenes. A "select" with more than
one case does some allocation. The Go compiler generates special-case code for
a single-case select. More than one case uses a complicated N-case library
function that does some allocation.

Passing a parameter as an "interface{}", or creating a slice, also causes the
creation of temporary objects, which are usually (always?) on the heap. This
may or may not be a big problem depending on how the allocator and garbage
collector work. Anyone know?

