Skip to content

Instantly share code, notes, and snippets.

@dustismo
Created July 12, 2013 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dustismo/5986631 to your computer and use it in GitHub Desktop.
Save dustismo/5986631 to your computer and use it in GitHub Desktop.
How to have a clean exit from golang
killchan := make(chan os.Signal, 2)
signal.Notify(killchan, os.Interrupt, syscall.SIGTERM)
// wait for kill signal
<- killchan
log.Println("Kill sig!")
//do clean up
//now exit
os.Exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment