Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CancelOnSignal ¶
func CancelOnSignal(cancel context.CancelFunc)
CancelOnSignal is a compact, idiomatic way to listen for OS signals in the main of a Go program. The intent here is to reduce the tedium of setting up proper signal handling and just compact the whole thing into what Go writers are used to dealing with: context cancellations. Usage looks like this:
func main() { ctx, cancel := context.WithCancel(context.Background()) go sigcancel.CancelOnSignal(cancel) go startWorking(ctx) <-ctx.Done() fmt.Println("shutting down...") // clean up services / workload }
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.