Hacker News new | ask | show | jobs
by kbolino 446 days ago
Basically, anything that isn't a thin pointer (*T, chan, map) gets boxed nowadays. The end result is that both words of an interface value are always pointers [1], which is very friendly to the garbage collector (setting aside the extra allocations when escape analysis fails). I've seen some tricks in the standard library to avoid boxing, e.g. how strings and times are handled by log/slog [2].

[1]: https://github.com/teh-cmc/go-internals/blob/master/chapter2...

[2]: https://cs.opensource.google/go/go/+/refs/tags/go1.24.1:src/...

1 comments

slog.Value looks incredibly useful.

Just imagine a day where database/sql doesn't generate a tonne of garbage because it moves to use something like that?