]> Cypherpunks repositories - gostls13.git/commitdiff
testing: style change: omit unnecessary new
authorIan Lance Taylor <iant@golang.org>
Sat, 20 Dec 2014 01:31:16 +0000 (17:31 -0800)
committerIan Lance Taylor <iant@golang.org>
Sat, 20 Dec 2014 01:40:11 +0000 (01:40 +0000)
This was brought to my attention because a user thought that because
the file was named "example.go" it served as an example of good coding
practice.  It's not an example, of course, but may as well use a more
idiomatic style anyhow.

Change-Id: I7aa720f603f09f7d597fb7536dbf46ef09144e28
Reviewed-on: https://go-review.googlesource.com/1902
Reviewed-by: Minux Ma <minux@golang.org>
src/testing/example.go

index f5762e4db4ab4278790861481951da4a5c20e9d3..61339a6465f699b9cbb77472e6542657b883dfa0 100644 (file)
@@ -56,8 +56,8 @@ func runExample(eg InternalExample) (ok bool) {
        os.Stdout = w
        outC := make(chan string)
        go func() {
-               buf := new(bytes.Buffer)
-               _, err := io.Copy(buf, r)
+               var buf bytes.Buffer
+               _, err := io.Copy(&buf, r)
                r.Close()
                if err != nil {
                        fmt.Fprintf(os.Stderr, "testing: copying pipe: %v\n", err)