markbates / sigtx

a context implementation for signal capturing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sigtx Build Status

This package provides an implementation proposal for this Go proposal: golang/go#21521.

Usage

package main

import (
	"context"
	"fmt"
  "os"
  "syscall"

	"github.com/markbates/sigtx"
)

func main() {
	ctx, cancel := sigtx.WithCancel(context.Background(), os.Interrupt, syscall.SIGTERM, syscall.SIGKILL)
	defer cancel()
	select {
	case <-ctx.Done():
		fmt.Println("thanks for stopping me")
	}
}

About

a context implementation for signal capturing

License:MIT License


Languages

Language:Go 100.0%