mirror of
https://github.com/golang/go
synced 2024-11-18 08:54:45 -07:00
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)
|
||||
}
|
||||
robots, err := ioutil.ReadAll(res.Body)
|
||||
res.Body.Close()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
res.Body.Close()
|
||||
fmt.Printf("%s", robots)
|
||||
}
|
||||
|
||||
|
@ -160,11 +160,11 @@ func TestTransportConnectionCloseOnResponse(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("error in connectionClose=%v, req #%d, Do: %v", connectionClose, n, err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
t.Fatalf("error in connectionClose=%v, req #%d, ReadAll: %v", connectionClose, n, err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
return string(body)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user