Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(853)

Delta Between Two Patch Sets: src/pkg/net/http/example_test.go

Issue 6458158: code review 6458158: net/http: fix misplaced defer and example (Closed)
Left Patch Set: diff -r 7c5f4dad8fae https://code.google.com/p/go Created 11 years, 7 months ago
Right Patch Set: diff -r 26b62d1db69f https://go.googlecode.com/hg/ Created 11 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/net/http/transport_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2012 The Go Authors. All rights reserved. 1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package http_test 5 package http_test
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "io/ioutil" 9 "io/ioutil"
10 "log" 10 "log"
(...skipping 25 matching lines...) Expand all
36 bufrw.Flush() 36 bufrw.Flush()
37 }) 37 })
38 } 38 }
39 39
40 func ExampleGet() { 40 func ExampleGet() {
41 res, err := http.Get("http://www.google.com/robots.txt") 41 res, err := http.Get("http://www.google.com/robots.txt")
42 if err != nil { 42 if err != nil {
43 log.Fatal(err) 43 log.Fatal(err)
44 } 44 }
45 robots, err := ioutil.ReadAll(res.Body) 45 robots, err := ioutil.ReadAll(res.Body)
46 » defer res.Body.Close() 46 » res.Body.Close()
47 if err != nil { 47 if err != nil {
48 log.Fatal(err) 48 log.Fatal(err)
49 } 49 }
50 fmt.Printf("%s", robots) 50 fmt.Printf("%s", robots)
51 } 51 }
52 52
53 func ExampleFileServer() { 53 func ExampleFileServer() {
54 // we use StripPrefix so that /tmpfiles/somefile will access /tmp/somefi le 54 // we use StripPrefix so that /tmpfiles/somefile will access /tmp/somefi le
55 http.Handle("/tmpfiles/", http.StripPrefix("/tmpfiles/", http.FileServer (http.Dir("/tmp")))) 55 http.Handle("/tmpfiles/", http.StripPrefix("/tmpfiles/", http.FileServer (http.Dir("/tmp"))))
56 } 56 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b