Tiny library for manage you application shutdown in graceful way by catching the OS signals.
os/signal.NotifyContext
instead
go get -u github.com/heartwilltell/waitabit
package main
import (
"log"
"os"
"github.com/heartwilltell/waitabit"
)
func main() {
// call your application here ...
wait := waitabit.NewWait(os.Interrupt)
wait.WaitWithFunc(func() {
log.Println("Bye")
})
// or ...
waitabit.NewWait(os.Interrupt).WaitWithFunc(func() {
log.Println("Bye")
})
}