mirror of https://github.com/golang/go.git
net/http: fix misplaced defer and example
Moves the defer (again). Also, correct the example documentation to match. R=r, robert.hencke, iant, dsymonds, bradfitz CC=golang-dev https://golang.org/cl/6458158
This commit is contained in:
parent
2bdc60f8e7
commit
46c9346d74
|
|
@ -43,10 +43,10 @@ func ExampleGet() {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
robots, err := ioutil.ReadAll(res.Body)
|
robots, err := ioutil.ReadAll(res.Body)
|
||||||
|
res.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
res.Body.Close()
|
|
||||||
fmt.Printf("%s", robots)
|
fmt.Printf("%s", robots)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,11 +160,11 @@ func TestTransportConnectionCloseOnResponse(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error in connectionClose=%v, req #%d, Do: %v", connectionClose, n, err)
|
t.Fatalf("error in connectionClose=%v, req #%d, Do: %v", connectionClose, n, err)
|
||||||
}
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
body, err := ioutil.ReadAll(res.Body)
|
body, err := ioutil.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error in connectionClose=%v, req #%d, ReadAll: %v", connectionClose, n, err)
|
t.Fatalf("error in connectionClose=%v, req #%d, ReadAll: %v", connectionClose, n, err)
|
||||||
}
|
}
|
||||||
defer res.Body.Close()
|
|
||||||
return string(body)
|
return string(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue