• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.gitignoreH A D31-Mar-2014259

LICENSEH A D31-Mar-20141.1 KiB

README.mdH A D31-Mar-2014774

cleanup.goH A D31-Mar-20141.4 KiB

cleanup_suite_test.goH A D31-Mar-2014196

cleanup_test.goH A D31-Mar-2014878

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.