Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NotifyContext ¶
NotifyContext returns a derived context from the parent context with a cancel function. It sets up a signal channel to listen for the specified signals and cancels the context when any of those signals are received. If a second signal is received, it exits the program with a status code of 1.
Example usage:
ctx := signal.NotifyContext(parentContext, os.Interrupt, syscall.SIGTERM) go func() { <-ctx.Done() // Perform cleanup or other tasks before exiting }()
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.