package main
import (
"context"
"log"
"net/http"
)
func main() {
r, _ := http.NewRequest("GET", "http://example.com", nil)
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
r = r.WithContext(ctx)
ch := make(chan bool)
go func() {
_, err := http.DefaultClient.Do(r)
log.Println(err == context.Canceled)
ch <- true
}()
cancel()
<-ch
}--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.