An open API service indexing awesome lists of open source software.

https://github.com/aklinkert/go-exitcontext

Provides an easy way of handling exit signals in go by providing a context
https://github.com/aklinkert/go-exitcontext

exit exitcode exitcontext golang golang-library golang-package signal signals

Last synced: 9 months ago
JSON representation

Provides an easy way of handling exit signals in go by providing a context

Awesome Lists containing this project

README

          

# go-exitcontext

This package provides functions to create a context that listens for `SIG_` signals and cancels the context, used to abort programs by sending signals.

# Usage

If you already have a context and want to recycle that one:

```go
ctx := context.Background()
exitCtx := exitcontext.NewWithContext(ctx)
```

else just use the new method, which creates a `context.Background()` under the hood:

```go
exitCtx := exitcontext.New()
```

## License

MIT License

Copyright (c) 2019 Alexander Pinnecke