1
0
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:
Dave Cheney 2012-08-21 11:46:07 +10:00
parent 2bdc60f8e7
commit 46c9346d74
2 changed files with 2 additions and 2 deletions

View File

@ -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)
}

View File

@ -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)
}