mirror of
https://github.com/hairyhenderson/go-onerng.git
synced 2025-07-08 03:15:08 -05:00
Some incomplete initial code
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
This commit is contained in:
31
cmd/onerng/main.go
Normal file
31
cmd/onerng/main.go
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user