Proposal Details
I propose such a function to the context package:
func Sleep(ctx Context, dur time.Duration) error {
select {
case <- ctx.Done():
return ctx.Err()
case <- time.After(d):
return nil
}
}
Rationale time.Sleep is a dangerous to use in a context-aware code as it is blocking. The only option is to use an inlined version of an above select{} statement, but it is quite verbose, so people use time.Sleep due to laziness