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

2017-11-08 Thread Glen Huang
Yep, that's a good way too. Thanks. Ain also posted it on SO. On Wednesday, November 8, 2017 at 8:20:25 PM UTC+8, Jan Mercl wrote: > > On Wed, Nov 8, 2017 at 1:12 PM Glen Huang > > wrote: > > see https://play.golang.org/p/wMJ5PX1x9H > > -- > > -j > -- You received this message because you are

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

2017-11-08 Thread Glen Huang
Really neat! Didn't know it was wrapped. Thank you. On Wednesday, November 8, 2017 at 8:17:59 PM UTC+8, Jakob Borg wrote: > > Errors from net/http are wrapped in an url.Error to contain information > about the request that failed. You can unwrap it with an assertion or type > switch; > > _, err

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

2017-11-08 Thread Jan Mercl
On Wed, Nov 8, 2017 at 1:12 PM Glen Huang wrote: see 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 golang-nuts+u

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

2017-11-08 Thread Jakob Borg
Errors from net/http are wrapped in an url.Error to contain information about the request that failed. You can unwrap it with an assertion or type switch; _, err := http.DefaultClient.Do(r) if urlErr, ok := err.(*url.Error); ok { log.Println(urlErr.Err == context.Canceled) // “true", in your exam