README.md
1GoCleanup
2=========
3
4It's kinda like atexit()
5
6GoCleanup is a big bag of singleton methods to enable `atexit`-like behavior in Golang. If you don't like singletons... move along ;)
7
8It's simple. You register functions to run on exit with
9
10```go
11gocleanup.Register(func() {
12 //do stuff
13})
14```
15
16If the running program receives a SIGINT, or SIGTERM cleanup will intercept the signal, run all the registered clean up functions and then exit with status 1.
17
18If you want to exit from within your code, you'll need to call
19
20```go
21gocleanup.Exit(statuscode)
22```
23
24to ensure the cleanup callbacks are run.
25
26Finally, if you want to manually invoke the cleanup callbacks (without exiting):
27
28```go
29gocleanup.Cleanup()
30```
31
32this will also unregister any registered cleanup functions.