Re: [go-nuts] How to check if a request was cancelled

2017-11-08 Thread Glen Huang
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 wrote: > > (expanding the code from the link) > > _, err := http.Defa

Re: [go-nuts] How to check if a request was cancelled

2017-11-08 Thread Jakob Borg
(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 succeede