package main import ( "context" "os" "os/signal" "syscall" ) func main() { failed := false defer func() { if failed { os.Exit(1) } }() ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) defer cancel() failed = run(ctx) != nil }