gocleanup

package module
v0.0.0-...-c1a5478 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2014 License: MIT Imports: 3 Imported by: 16

README

GoCleanup

It's kinda like atexit()

GoCleanup is a big bag of singleton methods to enable atexit-like behavior in Golang. If you don't like singletons... move along ;)

It's simple. You register functions to run on exit with

gocleanup.Register(func() {
    //do stuff
})

If 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.

If you want to exit from within your code, you'll need to call

gocleanup.Exit(statuscode)

to ensure the cleanup callbacks are run.

Finally, if you want to manually invoke the cleanup callbacks (without exiting):

gocleanup.Cleanup()

this will also unregister any registered cleanup functions.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cleanup

func Cleanup()

Cleanup invokes all registered cleanup functions all registered cleanup functions are subsequently removed

func Exit

func Exit(status int)

Exit invokes all registered cleanup functions, then exits

func Register

func Register(f func())

Register a cleanup function. This will be called when: - a call is made to Cleanup() - a call is made to Exit() - the current process receives SIGINT or SIGTERM

Types

This section is empty.

Jump to

Keyboard shortcuts

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