Clone this repo:

Branches

  1. dd0db47 Update pre-commit-go to pcg. by Marc-Antoine Ruel · 1 year, 12 months ago master
  2. 5aad64d Add ErrInterrupted. by Marc-Antoine Ruel · 2 years, 1 month ago
  3. 4821344 Switch from git-hooks-go to pre-commit-go by Marc-Antoine Ruel · 2 years, 3 months ago
  4. 5c2eb81 Update git-hooks-go to be compatible with go1.4. by Marc-Antoine Ruel · 2 years, 5 months ago
  5. 58e7ad0 Improve README.md and code coverage a bit. by Marc-Antoine Ruel · 2 years, 7 months ago

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