Add project documentation and licensing
[go-signalcontext.git] / cmd / example / main.go
1 package main
2
3 import (
4 "context"
5 "log"
6 "os"
7 "syscall"
8 "time"
9
10 "git.korewanetadesu.com/go-signalcontext"
11 )
12
13 func main() {
14 log.Print("waiting 10 seconds or until signal...")
15 p, cancel := context.WithTimeout(context.Background(), time.Second*10)
16 ctx := signalcontext.UntilSignal(p, os.Interrupt, syscall.SIGTERM)
17 <-ctx.Done()
18 cancel()
19 log.Print(ctx.Err())
20 }