Clone this repo:
  1. f781a91 Add go.mod by Marc-Antoine Ruel · 3 years, 9 months ago master v1.0.2
  2. 4927dd3 Remove dependency on github.com/maruel/ut by Marc-Antoine Ruel · 7 years ago v1.0.1
  3. d27c852 I meant 1.8.x instead of 1.8.0 by Marc-Antoine Ruel · 7 years ago
  4. 926ddba Bump travis to go 1.8 and 1.x by Marc-Antoine Ruel · 7 years ago
  5. dd0db47 Update pre-commit-go to pcg. by Marc-Antoine Ruel · 9 years ago v1.0.0

interrupt

Package interrupt is a single global way to handle process interruption.

It is useful for both long lived process to implement controlled shutdown and for CLI tool to handle early termination.

The interrupt signal can be set exactly once in the process lifetime and cannot be unset. The signal can optionally be set automatically on Ctrl-C/os.Interrupt. When set, it is expected the process to abort any on-going execution early.

The signal can be read via two ways:

select {
case <- interrupt.Channel:
  // Handle abort.
case ...
  ...
default:
}

or

if interrupt.IsSet() {
  // Handle abort.
}

GoDoc Build Status Coverage Status