Go does not have an
atexit library (
and will probably never have). Below is a small implementation of such a
library. Note that you have to use
atexit.Exit and not
os.Exit in your program.
As usual, you can install with
goinstall bitbucket.org/tebeka/atexit
And here is an example program (the funky import is due to running this program as a test in the source directory)