Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCancelOnSigInt ¶
WithCancelOnSigInt creates a child context that can be cancelled when a SIGINT signal (Ctrl+C) is received. The parent context is passed as an argument and the function returns the created child context.
The function starts a goroutine to listen for the SIGINT signal and calls the cancel function of the child context when the signal is received.
Example usage:
parentCtx := context.Background() childCtx := WithCancelOnSigInt(parentCtx) // use childCtx in your code...
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.