File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,3 +28,7 @@ fuzz: mod-tidy generate
2828cover : mod-tidy generate
2929 go test -v -count=1 -covermode=atomic -coverprofile=cover.out -coverpkg=./... ./...
3030 go tool cover -html=cover.out
31+
32+ .PHONY : docs
33+ docs :
34+ go run golang.org/x/pkgsite/cmd/pkgsite@latest -http=:8080
Original file line number Diff line number Diff line change 22package main
33
44import (
5+ "context"
6+ "os"
7+ "os/signal"
8+ "syscall"
9+
510 "github.com/alecthomas/kong"
611)
712
@@ -12,10 +17,14 @@ type CLI struct {
1217}
1318
1419func main () {
20+ ctx , stop := signal .NotifyContext (
21+ context .Background (), os .Interrupt , syscall .SIGTERM )
22+ defer stop ()
1523 // parse CLI config
1624 cli := CLI {}
1725 kctx := kong .Parse (& cli ,
1826 kong .UsageOnError (),
27+ kong .BindFor (ctx ),
1928 )
2029 // execute CLI
2130 kctx .FatalIfErrorf (kctx .Run ())
Original file line number Diff line number Diff line change 11package main
22
33import (
4+ "context"
45 "fmt"
56 "time"
67
@@ -11,7 +12,7 @@ import (
1112type ServeCmd struct {}
1213
1314// Run the serve command.
14- func (* ServeCmd ) Run () error {
15+ func (* ServeCmd ) Run (ctx context. Context ) error {
1516 fmt .Println (server .New (time .Now ).Serve ())
1617 return nil
1718}
Original file line number Diff line number Diff line change 11package main
22
33import (
4+ "context"
45 "encoding/json"
56 "fmt"
67 "runtime"
1819type VersionCmd struct {}
1920
2021// Run the Version command.
21- func (* VersionCmd ) Run () error {
22+ func (* VersionCmd ) Run (ctx context. Context ) error {
2223 v , err := json .Marshal (
2324 struct {
2425 ProjectName string
You can’t perform that action at this time.
0 commit comments