This package provides an implementation proposal for this Go proposal: golang/go#21521.
package main
import (
"context"
"fmt"
"os"
"syscall"
"github.com/markbates/sigtx"
)
func main() {
ctx, cancel := sigtx.WithCancel(context.Background(), os.Interrupt, syscall.SIGTERM, syscall.SIGKILL)
defer cancel()
select {
case <-ctx.Done():
fmt.Println("thanks for stopping me")
}
}