In my case the client is the sole consumer of the context, so it should be fine.
But I agree, checking error directly is more bullet-proof. I should probably form a habit adopting it. > On 8 Nov 2017, at 8:40 PM, Jakob Borg <[email protected]> wrote: > > (expanding the code from the link) > > _, err := http.DefaultClient.Do(r) > log.Println(err, ctx.Err() == context.Canceled) > > Note that, to be pedantic, this only tells you that the context has been > cancelled - not that that was the error returned by the HTTP request. The > HTTP request may have succeeded, or failed for another reason, before the > context was cancelled. Whether this matters is of course up to the > application. > > //jb > > >> On 8 Nov 2017, at 13:19, Jan Mercl <[email protected] >> <mailto:[email protected]>> wrote: >> >> On Wed, Nov 8, 2017 at 1:12 PM Glen Huang <[email protected] >> <mailto:[email protected]>> wrote: >> >> see https://play.golang.org/p/wMJ5PX1x9H >> <https://play.golang.org/p/wMJ5PX1x9H> >> >> -- >> -j >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] >> <mailto:[email protected]>. >> For more options, visit https://groups.google.com/d/optout >> <https://groups.google.com/d/optout>. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
