Some incomplete initial code

Signed-off-by: Dave Henderson <dhenderson@gmail.com>
This commit is contained in:
Dave Henderson
2018-08-01 23:46:37 -04:00
parent d45c09fb92
commit 926b9f6304
10 changed files with 542 additions and 0 deletions

31
cmd/onerng/main.go Normal file
View File

@ -0,0 +1,31 @@
package main
import (
"context"
"os"
"os/signal"
"time"
"github.com/hairyhenderson/go-onerng/cmd"
)
func main() {
ctx := context.Background()
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(3*time.Second))
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
defer func() {
signal.Stop(c)
cancel()
}()
go func() {
select {
case <-c:
cancel()
case <-ctx.Done():
}
}()
cmd.Execute(ctx)
}