Note that you have to call atexit.Exit
and not os.Exit
to terminate your
program (that is, if you want the atexit
handlers to execute).
package main
import (
"fmt"
"github.com/tebeka/atexit"
)
func handler() {
fmt.Println("Exiting")
}
func main() {
atexit.Register(handler)
atexit.Exit(0)
}
go get github.com/tebeka/atexit