iperf3exporter/vendor/github.com/caarlos0/ctrlc
Marvin Preuss 2343c9588a
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is failing
first commit
2021-10-20 10:08:56 +02:00
..
ctrlc.go first commit 2021-10-20 10:08:56 +02:00
LICENSE.md first commit 2021-10-20 10:08:56 +02:00
README.md first commit 2021-10-20 10:08:56 +02: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
    })
}