]> Cypherpunks repositories - gostls13.git/commitdiff
net/http/httptrace: fix bad tracing example
authorJaana Burcu Dogan <jbd@google.com>
Tue, 20 Sep 2016 03:36:45 +0000 (20:36 -0700)
committerJaana Burcu Dogan <jbd@google.com>
Tue, 20 Sep 2016 05:11:45 +0000 (05:11 +0000)
Tracing happens at the http.Trace level. Fix the example to demostrate
tracing in the lifecycle of a RoundTrip.

Updates #17152.

Change-Id: Ic7d7bcc550176189206185482e8962dbf1504ff1
Reviewed-on: https://go-review.googlesource.com/29431
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/net/http/httptrace/example_test.go

index 3a4b35469c9aa5cb7eafa23e34ad5f6ab8221a54..07fdc0a4726fc35e9f1b776171eb10e404e0e096 100644 (file)
@@ -6,6 +6,7 @@ package httptrace_test
 
 import (
        "fmt"
+       "log"
        "net/http"
        "net/http/httptrace"
 )
@@ -21,5 +22,8 @@ func Example() {
                },
        }
        req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace))
-       http.DefaultClient.Do(req)
+       _, err := http.DefaultTransport.RoundTrip(req)
+       if err != nil {
+               log.Fatal(err)
+       }
 }