logginghandler/vendor/github.com/caarlos0/ctrlc
Marvin Preuss d095180eb4
All checks were successful
continuous-integration/drone/push Build is passing
build: uses go modules for tool handling
2022-01-14 13:51:56 +01:00
..
ctrlc.go build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
LICENSE.md build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00
README.md build: uses go modules for tool handling 2022-01-14 13:51:56 +01:00

ctrlc

CTRL-C is a Go library that provides an easy way of having a task that is context-aware and deals with SIGINT and SIGTERM signals.

Usage

package main

import "context"
import "github.com/caarlos0/ctrlc"

func main() {
    ctx, cancel := context.WithTimeout(context.Backgroud(), time.Second)
    defer cancel()
    ctrlc.Default.Run(ctx, func() error {
        // do something
        return nil
    })
}