// sigterm package main import ( "os" "os/signal" "syscall" ) func exit() { done <- true } func setTerm() { c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) signal.Notify(c, syscall.SIGTERM) go func() { <-c exit() }() }