Help us shape the future of Go! Take the 2026 Go Developer Survey

lifecycle

package
v1.4.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SignalMessage

func SignalMessage(sig os.Signal) string

SignalMessage returns a human-readable message for a signal. SIGINT → "Interrupted. Cleaning up..." SIGTERM → "Terminating. Cleaning up..." other → "Signal received. Cleaning up..."

func TrapSignals

func TrapSignals(ctx context.Context, cancel context.CancelFunc, cleanupFn func(), timeout time.Duration, exitFn func(int))

TrapSignals registers SIGINT and SIGTERM handlers. On signal: prints a message via ui.Warn, calls cancel(), runs cleanupFn in a goroutine, waits up to timeout for it to complete, then calls exitFn with the conventional signal exit code (130 for SIGINT, 143 for SIGTERM). Pass os.Exit as exitFn in production; pass a stub in tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL