Replace select with simpler error check

The documentation for Context states that this is just as good:
	// If Done is not yet closed, Err returns nil.
	// If Done is closed, Err returns a non-nil error

Signed-off-by: Bryan Boreham <bryan@weave.works>
This commit is contained in:
Bryan Boreham 2019-01-23 15:13:11 +00:00 committed by Brian Brazil
parent cc75c27580
commit e4a37d0986

View File

@ -182,12 +182,10 @@ func (q *query) Exec(ctx context.Context) *Result {
// contextDone returns an error if the context was canceled or timed out.
func contextDone(ctx context.Context, env string) error {
select {
case <-ctx.Done():
return contextErr(ctx.Err(), env)
default:
return nil
if err := ctx.Err(); err != nil {
return contextErr(err, env)
}
return nil
}
func contextErr(err error, env string) error {