-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
good first issueGood for newcomersGood for newcomers
Description
Simplified example:
// Run runs server until ctx is canceled, then stops it gracefully and exits.
func RunHandler(ctx context.Context) {
s := http.Server{
BaseContext: func(_ net.Listener) context.Context {
return ctx
},
}
go s.ListenAndServe()
<-ctx.Done()
// use new context for cancelation
stopCtx, stopCancel := context.WithTimeout(context.Background(), time.Second)
defer stopCancel()
s.Shutdown(stopCtx)
s.Close()
}stopCtx can't be inherited from ctx as the later is already canceled.
Maybe this linter can detect that <-ctx.Done() was already called by this point?
vlad-tokarev, nawa, benjaminbartels, jlourenc, sergeyshevch and 11 more
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers