Add example code
This commit is contained in:
parent
5da0055618
commit
61dfc5d02b
|
@ -2,4 +2,6 @@
|
|||
|
||||
A simple library for graceful shutdowns
|
||||
|
||||
100% covered with unit tests.
|
||||
100% covered with unit tests.
|
||||
|
||||
See and try the example in `/example` to see the how things should be done.
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
goshutdowner "git.jlel.se/jlelse/go-shutdowner"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
// Declare shutdowner
|
||||
var sd goshutdowner.Shutdowner
|
||||
|
||||
// Add a function to execute on shutdown
|
||||
sd.Add(func() {
|
||||
log.Println("Shutdown")
|
||||
})
|
||||
|
||||
log.Println("Started")
|
||||
|
||||
// CTRL + C or otherwise interrupt the program
|
||||
|
||||
// Wait for shutdowner to finish
|
||||
sd.Wait()
|
||||
|
||||
}
|
Loading…
Reference in New Issue