tl;dr: Looking forward future Pinner.Pin performance improvements.

The upcoming Go version 1.21, scheduled for release next month, is currently available for download as Go 1.21rc2 in the “Unstable version” section here. Go 1.21 introduces a new runtime type, Pinner.

ccgo/v4, the next, also not yet released version of the C to Go transpiler, uses pinning to “freeze” addresses of local Go variables, addresses of which are passed around in the original C code. ccgo produces Go code where any C pointer points to memory not managed by the Go runtime. So ccgo simply puts such “escaping” variables in the memory not visible to the garbage collector, with stable, immovable addresses. Those are provided by the modernc.org/memory package. Otherwise a goroutine stack resizing can change the address of a local variable.