package module
Version: v0.0.0-...-e7c30c7 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2023 License: BSD-3-Clause Imports: 0 Imported by: 9


If your Go package wants to declare that it plays unsafe games that only work if the Go runtime's garbage collector is not a moving collector, then add:

import _ ""

Then your program will explode if that's no longer the case. (Users can override the explosion with a scary sounding environment variable.)

This also gives us a way to find all the really gross unsafe packages.



Package exists so you can depend on it from unsafe code that wants to declare that it assumes that the Go runtime does not using a moving garbage collector. Specifically, it asserts that the caller is playing stupid games with the addresses of heap-allocated values. It says nothing about values that Go's escape analysis keeps on the stack. Ensuring things aren't stack-allocated is the caller's responsibility.

This package is then updated as needed for new Go versions when that is still the case and explodes at runtime with a failure otherwise, with the idea that it's better to not start at all than to silently corrupt your data at runtime.

To use:

import _ ""

There is no API.

As of Go 1.21, this package asks the Go runtime whether it can move heap objects around. If you get an error on versions prior to that, go get and things will work.

The GitHub repo is at

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL