]> Cypherpunks repositories - gostls13.git/commitdiff
bytes: make examples work in playground
authorAndrew Gerrand <adg@golang.org>
Wed, 10 Oct 2012 00:15:41 +0000 (11:15 +1100)
committerAndrew Gerrand <adg@golang.org>
Wed, 10 Oct 2012 00:15:41 +0000 (11:15 +1100)
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6633050

src/pkg/bytes/example_test.go

index 6fe8cd5a90cc3736eeb7ade9cd648cdf26ca9cef..1774a5ab42612a563b702f696e06d3c7d9fbd686 100644 (file)
@@ -5,23 +5,24 @@
 package bytes_test
 
 import (
-       "bytes"
+       "bytes"
        "encoding/base64"
+       "fmt"
        "io"
        "os"
 )
 
 func ExampleBuffer() {
-       var b Buffer // A Buffer needs no initialization.
+       var b bytes.Buffer // A Buffer needs no initialization.
        b.Write([]byte("Hello "))
-       b.Write([]byte("world!"))
+       fmt.Fprintf(&b, "world!")
        b.WriteTo(os.Stdout)
        // Output: Hello world!
 }
 
 func ExampleBuffer_reader() {
        // A Buffer can turn a string or a []byte into an io.Reader.
-       buf := NewBufferString("R29waGVycyBydWxlIQ==")
+       buf := bytes.NewBufferString("R29waGVycyBydWxlIQ==")
        dec := base64.NewDecoder(base64.StdEncoding, buf)
        io.Copy(os.Stdout, dec)
        // Output: Gophers rule!