]> Cypherpunks repositories - gostls13.git/commitdiff
rename bytes.Buffer.Data() to bytes.Buffer.Bytes()
authorRob Pike <r@golang.org>
Wed, 16 Sep 2009 22:15:00 +0000 (15:15 -0700)
committerRob Pike <r@golang.org>
Wed, 16 Sep 2009 22:15:00 +0000 (15:15 -0700)
R=rsc
DELTA=152  (6 added, 0 deleted, 146 changed)
OCL=34695
CL=34701

30 files changed:
src/cmd/ebnflint/ebnflint.go
src/cmd/godoc/godoc.go
src/pkg/archive/tar/writer_test.go
src/pkg/base64/base64_test.go
src/pkg/bufio/bufio_test.go
src/pkg/bytes/buffer.go
src/pkg/bytes/buffer_test.go
src/pkg/compress/gzip/gunzip_test.go
src/pkg/compress/zlib/reader_test.go
src/pkg/crypto/block/cbc_aes_test.go
src/pkg/crypto/block/cfb_aes_test.go
src/pkg/crypto/block/ctr_aes_test.go
src/pkg/crypto/block/eax_aes_test.go
src/pkg/crypto/block/ecb_aes_test.go
src/pkg/crypto/block/ecb_test.go
src/pkg/crypto/block/ofb_aes_test.go
src/pkg/crypto/block/xor_test.go
src/pkg/datafmt/datafmt.go
src/pkg/exvar/exvar.go
src/pkg/go/parser/interface.go
src/pkg/go/printer/printer_test.go
src/pkg/gob/codec_test.go
src/pkg/http/triv.go
src/pkg/io/utils.go
src/pkg/json/parse.go
src/pkg/os/os_test.go
src/pkg/regexp/regexp.go
src/pkg/tabwriter/tabwriter.go
src/pkg/template/format.go
src/pkg/template/template_test.go

index f6374214bd6f55449859a3aa4605a7adc5bb72da..76281597270fc9a3d6cd75ce743b4ab4cffbe916 100644 (file)
@@ -68,7 +68,7 @@ func extractEBNF(src []byte) []byte {
                src = src[j : len(src)];
        }
 
-       return buf.Data();
+       return buf.Bytes();
 }
 
 
index d3a4bc342c30f46e7027c3996fd340628711d640..36e66a2110c54d7a2829897c47d5b06580ba951e 100644 (file)
@@ -264,7 +264,7 @@ func writeAny(w io.Writer, x interface{}, html bool) {
                if html {
                        var buf bytes.Buffer;
                        fmt.Fprint(&buf, x);
-                       writeText(w, buf.Data(), true);
+                       writeText(w, buf.Bytes(), true);
                } else {
                        fmt.Fprint(w, x);
                }
@@ -282,7 +282,7 @@ func htmlFmt(w io.Writer, x interface{}, format string) {
 func htmlCommentFmt(w io.Writer, x interface{}, format string) {
        var buf bytes.Buffer;
        writeAny(&buf, x, false);
-       doc.ToHtml(w, buf.Data());
+       doc.ToHtml(w, buf.Bytes());
 }
 
 
@@ -382,7 +382,7 @@ func serveParseErrors(c *http.Conn, errors *parseErrors) {
        if err := parseerrorHtml.Execute(errors, &buf); err != nil {
                log.Stderrf("parseerrorHtml.Execute: %s", err);
        }
-       servePage(c, errors.filename + " - Parse Errors", buf.Data());
+       servePage(c, errors.filename + " - Parse Errors", buf.Bytes());
 }
 
 
@@ -398,7 +398,7 @@ func serveGoSource(c *http.Conn, name string) {
        writeNode(&buf, prog, true);
        fmt.Fprintln(&buf, "</pre>");
 
-       servePage(c, name + " - Go source", buf.Data());
+       servePage(c, name + " - Go source", buf.Bytes());
 }
 
 
@@ -539,7 +539,7 @@ func servePkg(c *http.Conn, r *http.Request) {
                if err := packageText.Execute(info, &buf); err != nil {
                        log.Stderrf("packageText.Execute: %s", err);
                }
-               serveText(c, buf.Data());
+               serveText(c, buf.Bytes());
                return;
        }
 
@@ -550,7 +550,7 @@ func servePkg(c *http.Conn, r *http.Request) {
        if path == "" {
                path = ".";  // don't display an empty path
        }
-       servePage(c, path + " - Go package documentation", buf.Data());
+       servePage(c, path + " - Go package documentation", buf.Bytes());
 }
 
 
@@ -589,22 +589,22 @@ func exec(c *http.Conn, args []string) bool {
        io.Copy(r, &buf);
        wait, err := os.Wait(pid, 0);
        if err != nil {
-               os.Stderr.Write(buf.Data());
+               os.Stderr.Write(buf.Bytes());
                log.Stderrf("os.Wait(%d, 0): %v\n", pid, err);
                return false;
        }
        if !wait.Exited() || wait.ExitStatus() != 0 {
-               os.Stderr.Write(buf.Data());
+               os.Stderr.Write(buf.Bytes());
                log.Stderrf("executing %v failed (exit status = %d)", args, wait.ExitStatus());
                return false;
        }
 
        if *verbose {
-               os.Stderr.Write(buf.Data());
+               os.Stderr.Write(buf.Bytes());
        }
        if c != nil {
                c.SetHeader("content-type", "text/plain; charset=utf-8");
-               c.Write(buf.Data());
+               c.Write(buf.Bytes());
        }
 
        return true;
index 56697290fe70a1d56a67610c422e9527d61c55fe..40b78bb3226311add26b7323825131407d5a89fd 100644 (file)
@@ -121,7 +121,7 @@ testLoop:
                }
                tw.Close();
 
-               actual := buf.Data();
+               actual := buf.Bytes();
                if !bytes.Equal(expected, actual) {
                        t.Errorf("test %d: Incorrect result: (-=expected, +=actual)\n%v",
                                 i, bytediff(expected, actual));
index 69da2dfa7ff4bdcb15563062a441997f1d609a91..0537abab7c3779baf8930cdbc398ee9adef83d31 100644 (file)
@@ -73,7 +73,7 @@ func TestEncoder(t *testing.T) {
                encoder := NewEncoder(StdEncoding, bb);
                encoder.Write(strings.Bytes(p.decoded));
                encoder.Close();
-               testEqual(t, "Encode(%q) = %q, want %q", p.decoded, string(bb.Data()), p.encoded);
+               testEqual(t, "Encode(%q) = %q, want %q", p.decoded, string(bb.Bytes()), p.encoded);
        }
 }
 
@@ -93,7 +93,7 @@ func TestEncoderBuffering(t *testing.T) {
                }
                err := encoder.Close();
                testEqual(t, "Close gave error %v, want %v", err, os.Error(nil));
-               testEqual(t, "Encoding/%d of %q = %q, want %q", bs, bigtest.decoded, string(bb.Data()), bigtest.encoded);
+               testEqual(t, "Encoding/%d of %q = %q, want %q", bs, bigtest.decoded, string(bb.Bytes()), bigtest.encoded);
        }
 }
 
index 58e4456a64eac9628181f8599cf22856769b8ddb..78920eb408cf5f1ea8ecc867f62e112978b77b5f 100644 (file)
@@ -256,7 +256,7 @@ func TestWriter(t *testing.T) {
                                t.Errorf("%s: buf.Flush = %v", context, e);
                        }
 
-                       written := w.Data();
+                       written := w.Bytes();
                        if len(written) != nwrite {
                                t.Errorf("%s: %d bytes written", context, len(written));
                        }
@@ -372,7 +372,7 @@ func TestWriteString(t *testing.T) {
                t.Error("WriteString", b.err);
        }
        s := "01234567890abcdefghijklmnopqrstuvwxyz";
-       if string(buf.Data()) != s {
-               t.Errorf("WriteString wants %q gets %q", s, string(buf.Data()))
+       if string(buf.Bytes()) != s {
+               t.Errorf("WriteString wants %q gets %q", s, string(buf.Bytes()))
        }
 }
index 6c857069b081bd3c12f0cb2a42ae8e3f247d9ff5..fbaa93757aa07965309111aeb596198c819982da 100644 (file)
@@ -26,14 +26,20 @@ type Buffer struct {
        off     int;    // read at &buf[off], write at &buf[len(buf)]
 }
 
-// Data returns the contents of the unread portion of the buffer;
-// len(b.Data()) == b.Len().
-func (b *Buffer) Data() []byte {
+// Bytes returns the contents of the unread portion of the buffer;
+// len(b.Bytes()) == b.Len().
+func (b *Buffer) Bytes() []byte {
        return b.buf[b.off : len(b.buf)]
 }
 
+// String returns the contents of the unread portion of the buffer
+// as a string.
+func (b *Buffer) String() string {
+       return string(b.buf[b.off : len(b.buf)])
+}
+
 // Len returns the number of bytes of the unread portion of the buffer;
-// b.Len() == len(b.Data()).
+// b.Len() == len(b.Bytes()).
 func (b *Buffer) Len() int {
        return len(b.buf) - b.off
 }
index bb6593774a82fb197099beed5153124e28437d4d..79b5909bf6667f055e86d2c1fb08b7f53a6b0422 100644 (file)
@@ -25,16 +25,16 @@ func init() {
 
 // Verify that contents of buf match the string s.
 func check(t *testing.T, testname string, buf *Buffer, s string) {
-       if buf.Len() != len(buf.Data()) {
-               t.Errorf("%s: buf.Len() == %d, len(buf.Data()) == %d\n", testname, buf.Len(), len(buf.Data()))
+       if buf.Len() != len(buf.Bytes()) {
+               t.Errorf("%s: buf.Len() == %d, len(buf.Bytes()) == %d\n", testname, buf.Len(), len(buf.Bytes()))
        }
 
        if buf.Len() != len(s) {
                t.Errorf("%s: buf.Len() == %d, len(s) == %d\n", testname, buf.Len(), len(s))
        }
 
-       if string(buf.Data()) != s {
-               t.Errorf("%s: string(buf.Data()) == %q, s == %q\n", testname, string(buf.Data()), s)
+       if string(buf.Bytes()) != s {
+               t.Errorf("%s: string(buf.Bytes()) == %q, s == %q\n", testname, string(buf.Bytes()), s)
        }
 }
 
index 67b25791c960a6d6caa25bc898d42fc762157218..aef79244dc9126bb46c7a0166972e531e220b03d 100644 (file)
@@ -298,7 +298,7 @@ func TestInflater(t *testing.T) {
                if err != tt.err {
                        t.Errorf("%s: io.Copy: %v want %v", tt.name, err, tt.err);
                }
-               s := string(b.Data());
+               s := string(b.Bytes());
                if s != tt.raw {
                        t.Errorf("%s: got %d-byte %q want %d-byte %q", tt.name, n, s, len(tt.raw), tt.raw);
                }
index 9d250a1139696bcf9cf343a285e0e4b77bc6cf89..e1ebf6236e2e5cd22c60f08eda8945a5e6c76127 100644 (file)
@@ -95,7 +95,7 @@ func TestInflater(t *testing.T) {
                        }
                        continue;
                }
-               s := string(b.Data());
+               s := string(b.Bytes());
                if s != tt.raw {
                        t.Errorf("%s: got %d-byte %q want %d-byte %q", tt.desc, n, s, len(tt.raw), tt.raw);
                }
index 8a84feadd512881bdad5e7324a52c2be133bc793..8f7d5b4421cd6343025f598b8e656aa76099a647 100644 (file)
@@ -82,7 +82,7 @@ func TestCBC_AES(t *testing.T) {
                n, err := io.Copy(r, w);
                if n != int64(len(tt.in)) || err != nil {
                        t.Errorf("%s: CBCEncrypter io.Copy = %d, %v want %d, nil", test, n, err, len(tt.in));
-               } else if d := crypt.Data(); !same(tt.out, d) {
+               } else if d := crypt.Bytes(); !same(tt.out, d) {
                        t.Errorf("%s: CBCEncrypter\nhave %x\nwant %x", test, d, tt.out);
                }
 
@@ -92,7 +92,7 @@ func TestCBC_AES(t *testing.T) {
                n, err = io.Copy(r, w);
                if n != int64(len(tt.out)) || err != nil {
                        t.Errorf("%s: CBCDecrypter io.Copy = %d, %v want %d, nil", test, n, err, len(tt.out));
-               } else if d := plain.Data(); !same(tt.in, d) {
+               } else if d := plain.Bytes(); !same(tt.in, d) {
                        t.Errorf("%s: CBCDecrypter\nhave %x\nwant %x", test, d, tt.in);
                }
 
index bf719ad39be890b7fcc1fb292cc356c7a2a23a13..ce8627ed027c1fc37a60606550d206d049751e7f 100644 (file)
@@ -291,7 +291,7 @@ func TestCFB_AES(t *testing.T) {
                n, err := io.Copy(r, w);
                if n != int64(len(tt.in)) || err != nil {
                        t.Errorf("%s: CFBEncrypter io.Copy = %d, %v want %d, nil", test, n, err, len(tt.in));
-               } else if d := crypt.Data(); !same(tt.out, d) {
+               } else if d := crypt.Bytes(); !same(tt.out, d) {
                        t.Errorf("%s: CFBEncrypter\nhave %x\nwant %x", test, d, tt.out);
                }
 
@@ -301,7 +301,7 @@ func TestCFB_AES(t *testing.T) {
                n, err = io.Copy(r, w);
                if n != int64(len(tt.out)) || err != nil {
                        t.Errorf("%s: CFBDecrypter io.Copy = %d, %v want %d, nil", test, n, err, len(tt.out));
-               } else if d := plain.Data(); !same(tt.in, d) {
+               } else if d := plain.Bytes(); !same(tt.in, d) {
                        t.Errorf("%s: CFBDecrypter\nhave %x\nwant %x", test, d, tt.in);
                }
 
index 97ae1ebf787801f58dc7d8c1a1d7814e13abd265..d9c9c4b2ffe9bef380efe8bca2bc38e407abbdc4 100644 (file)
@@ -88,7 +88,7 @@ func TestCTR_AES(t *testing.T) {
                        n, err := io.Copy(r, w);
                        if n != int64(len(in)) || err != nil {
                                t.Errorf("%s/%d: CTRWriter io.Copy = %d, %v want %d, nil", test, len(in), n, err, len(in));
-                       } else if d, out := crypt.Data(), tt.out[0:len(in)]; !same(out, d) {
+                       } else if d, out := crypt.Bytes(), tt.out[0:len(in)]; !same(out, d) {
                                t.Errorf("%s/%d: CTRWriter\ninpt %x\nhave %x\nwant %x", test, len(in), in, d, out);
                        }
                }
@@ -101,7 +101,7 @@ func TestCTR_AES(t *testing.T) {
                        n, err := io.Copy(r, w);
                        if n != int64(len(out)) || err != nil {
                                t.Errorf("%s/%d: CTRReader io.Copy = %d, %v want %d, nil", test, len(out), n, err, len(out));
-                       } else if d, in := plain.Data(), tt.in[0:len(out)]; !same(in, d) {
+                       } else if d, in := plain.Bytes(), tt.in[0:len(out)]; !same(in, d) {
                                t.Errorf("%s/%d: CTRReader\nhave %x\nwant %x", test, len(out), d, in);
                        }
                }
index f90d54173af2aebc87f13a1863001f26d4d20cd1..2105c5accf8cb01ae193945d8dc5ca94af6ca23c 100644 (file)
@@ -212,7 +212,7 @@ func TestEAXEncrypt_AES(t *testing.T) {
                if err != nil {
                        t.Fatalf("%s: enc.Close: %s", test, err);
                }
-               if d := b.Data(); !same(d, tt.cipher) {
+               if d := b.Bytes(); !same(d, tt.cipher) {
                        t.Fatalf("%s: got %x want %x", test, d, tt.cipher);
                }
        }
@@ -232,7 +232,7 @@ func TestEAXDecrypt_AES(t *testing.T) {
                if n != int64(len(tt.msg)) || err != nil {
                        t.Fatalf("%s: io.Copy into decrypter: %d, %s", test, n, err);
                }
-               if d := b.Data(); !same(d, tt.msg) {
+               if d := b.Bytes(); !same(d, tt.msg) {
                        t.Fatalf("%s: got %x want %x", test, d, tt.msg);
                }
        }
index c9ce73f76da45095f3af6e65865623ef8f5a261a..65f093d84b0e6fa351951431ce668f7e829d49aa 100644 (file)
@@ -115,7 +115,7 @@ func TestECB_AES(t *testing.T) {
                n, err := io.Copy(r, w);
                if n != int64(len(tt.in)) || err != nil {
                        t.Errorf("%s: ECBReader io.Copy = %d, %v want %d, nil", test, n, err, len(tt.in));
-               } else if d := crypt.Data(); !same(tt.out, d) {
+               } else if d := crypt.Bytes(); !same(tt.out, d) {
                        t.Errorf("%s: ECBReader\nhave %x\nwant %x", test, d, tt.out);
                }
 
@@ -125,7 +125,7 @@ func TestECB_AES(t *testing.T) {
                n, err = io.Copy(r, w);
                if n != int64(len(tt.out)) || err != nil {
                        t.Errorf("%s: ECBWriter io.Copy = %d, %v want %d, nil", test, n, err, len(tt.out));
-               } else if d := plain.Data(); !same(tt.in, d) {
+               } else if d := plain.Bytes(); !same(tt.in, d) {
                        t.Errorf("%s: ECBWriter\nhave %x\nwant %x", test, d, tt.in);
                }
 
index 5160e112743ce008d37ed5f7c070832df2b3ad8e..b06cd3e2d8e9ca3f7e3ad78b8552261cedb7edc2 100644 (file)
@@ -96,7 +96,7 @@ func TestECBEncrypter(t *testing.T) {
                        }
 
                        // check output
-                       data := b.Data();
+                       data := b.Bytes();
                        if len(data) != len(crypt) {
                                t.Errorf("block=%d frag=%d: want %d bytes, got %d", block, frag, len(crypt), len(data));
                                continue;
@@ -161,7 +161,7 @@ func testECBDecrypter(t *testing.T, maxio int) {
                                }
 
                                // check output
-                               data := b.Data();
+                               data := b.Bytes();
                                if len(data) != maxio {
                                        t.Errorf("%s: want %d bytes, got %d", test, maxio, len(data));
                                        continue;
index 9b9f3679df8e570436ea1cd88822911b10a753ef..d9a10927950da558abaf5bd71ed5ea5a31e025b3 100644 (file)
@@ -84,7 +84,7 @@ func TestOFB_AES(t *testing.T) {
                        n, err := io.Copy(r, w);
                        if n != int64(len(in)) || err != nil {
                                t.Errorf("%s/%d: OFBWriter io.Copy = %d, %v want %d, nil", test, len(in), n, err, len(in));
-                       } else if d, out := crypt.Data(), tt.out[0:len(in)]; !same(out, d) {
+                       } else if d, out := crypt.Bytes(), tt.out[0:len(in)]; !same(out, d) {
                                t.Errorf("%s/%d: OFBWriter\ninpt %x\nhave %x\nwant %x", test, len(in), in, d, out);
                        }
                }
@@ -97,7 +97,7 @@ func TestOFB_AES(t *testing.T) {
                        n, err := io.Copy(r, w);
                        if n != int64(len(out)) || err != nil {
                                t.Errorf("%s/%d: OFBReader io.Copy = %d, %v want %d, nil", test, len(out), n, err, len(out));
-                       } else if d, in := plain.Data(), tt.in[0:len(out)]; !same(in, d) {
+                       } else if d, in := plain.Bytes(), tt.in[0:len(out)]; !same(in, d) {
                                t.Errorf("%s/%d: OFBReader\nhave %x\nwant %x", test, len(out), d, in);
                        }
                }
index c2818f01c64e33ed3cf29204de97942b7c8be89b..571ef4eb9d63e26ab81d0615ea40be77b7385c3c 100644 (file)
@@ -75,7 +75,7 @@ func testXorWriter(t *testing.T, maxio int) {
 
                        // check output
                        crypt := crypt[0:len(crypt) - frag];
-                       data := b.Data();
+                       data := b.Bytes();
                        if len(data) != len(crypt) {
                                t.Errorf("%s: want %d bytes, got %d", test, len(crypt), len(data));
                                continue;
@@ -142,7 +142,7 @@ func testXorReader(t *testing.T, maxio int) {
                                }
 
                                // check output
-                               data := b.Data();
+                               data := b.Bytes();
                                crypt := crypt[0:maxio - frag];
                                plain := plain[0:maxio - frag];
                                if len(data) != len(plain) {
index c3ac311410bad1a6b0a3dce4a937a0e0c7f44647..8918d5e97fbd99548a9d7976886a439165ea0b9d 100644 (file)
@@ -367,7 +367,7 @@ func (s *State) Write(data []byte) (int, os.Error) {
                if ch == '\n' || ch == '\f' {
                        // write text segment and indentation
                        n1, _ := s.output.Write(data[i0 : i+1]);
-                       n2, _ := s.output.Write(s.indent.Data());
+                       n2, _ := s.output.Write(s.indent.Bytes());
                        n += n1 + n2;
                        i0 = i + 1;
                        s.linePos.Offset = s.output.Len();
@@ -604,7 +604,7 @@ func (s *State) eval(fexpr expr, value reflect.Value, index int) bool {
                // if the indentation evaluates to nil, the state's output buffer
                // didn't change - either way it's ok to append the difference to
                // the current identation
-               s.indent.Write(s.output.Data()[mark.outputLen : s.output.Len()]);
+               s.indent.Write(s.output.Bytes()[mark.outputLen : s.output.Len()]);
                s.restore(mark);
 
                // format group body
@@ -691,7 +691,7 @@ func (f Format) Eval(env Environment, args ...) ([]byte, os.Error) {
        }();
 
        err := <- errors;
-       return s.output.Data(), err;
+       return s.output.Bytes(), err;
 }
 
 
@@ -732,5 +732,5 @@ func (f Format) Sprint(args ...) string {
        if err != nil {
                fmt.Fprintf(&buf, "--- Sprint(%s) failed: %v", fmt.Sprint(args), err);
        }
-       return string(buf.Data());
+       return string(buf.Bytes());
 }
index 7849714978945a55d3afa5b0cea41586e06069eb..abeeea725803b1aa0bc7751188759bbc76f79cc9 100644 (file)
@@ -64,7 +64,7 @@ func (v *Map) String() string {
                first = false;
        }
        fmt.Fprintf(b, "}");
-       return string(b.Data())
+       return string(b.Bytes())
 }
 
 func (v *Map) Init() *Map {
index bc13e2e51602810218c7803fb9ae9784a6cc110c..3ec75637b8ecef5ab69ab546f451b215b705c393 100644 (file)
@@ -34,7 +34,7 @@ func readSource(filename string, src interface{}) ([]byte, os.Error) {
                case *bytes.Buffer:
                        // is io.Reader, but src is already available in []byte form
                        if s != nil {
-                               return s.Data(), nil;
+                               return s.Bytes(), nil;
                        }
                case io.Reader:
                        var buf bytes.Buffer;
@@ -42,7 +42,7 @@ func readSource(filename string, src interface{}) ([]byte, os.Error) {
                        if err != nil {
                                return nil, err;
                        }
-                       return buf.Data(), nil;
+                       return buf.Bytes(), nil;
                default:
                        return nil, os.ErrorString("invalid source");
                }
index 65827de8e1b06a10340f8c5699db7a4e4da3363d..f9019fdacfc3932f6fdfe6863f8164bda2c9ab92 100644 (file)
@@ -53,7 +53,7 @@ func check(t *testing.T, source, golden string, exports bool) {
        if _, err := Fprint(&buf, prog, 0, tabwidth); err != nil {
                t.Error(err);
        }
-       res := buf.Data();
+       res := buf.Bytes();
 
        // update golden files if necessary
        if *update {
index 8eff37e0a4348b2ccb7e34dfb9e264e4d31b0727..3c75e4f855402cf1ea1fc5e0a7d986fefbaee222 100644 (file)
@@ -48,8 +48,8 @@ func TestUintCodec(t *testing.T) {
                if encState.err != nil {
                        t.Error("encodeUint:", tt.x, encState.err)
                }
-               if !bytes.Equal(tt.b, b.Data()) {
-                       t.Errorf("encodeUint: %#x encode: expected % x got % x", tt.x, tt.b, b.Data())
+               if !bytes.Equal(tt.b, b.Bytes()) {
+                       t.Errorf("encodeUint: %#x encode: expected % x got % x", tt.x, tt.b, b.Bytes())
                }
        }
        decState := newDecodeState(b);
@@ -134,8 +134,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encBool, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(boolResult, b.Data()) {
-                       t.Errorf("bool enc instructions: expected % x got % x", boolResult, b.Data())
+               if !bytes.Equal(boolResult, b.Bytes()) {
+                       t.Errorf("bool enc instructions: expected % x got % x", boolResult, b.Bytes())
                }
        }
 
@@ -146,8 +146,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encInt, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(signedResult, b.Data()) {
-                       t.Errorf("int enc instructions: expected % x got % x", signedResult, b.Data())
+               if !bytes.Equal(signedResult, b.Bytes()) {
+                       t.Errorf("int enc instructions: expected % x got % x", signedResult, b.Bytes())
                }
        }
 
@@ -158,8 +158,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encUint, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(unsignedResult, b.Data()) {
-                       t.Errorf("uint enc instructions: expected % x got % x", unsignedResult, b.Data())
+               if !bytes.Equal(unsignedResult, b.Bytes()) {
+                       t.Errorf("uint enc instructions: expected % x got % x", unsignedResult, b.Bytes())
                }
        }
 
@@ -170,8 +170,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encInt8, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(signedResult, b.Data()) {
-                       t.Errorf("int8 enc instructions: expected % x got % x", signedResult, b.Data())
+               if !bytes.Equal(signedResult, b.Bytes()) {
+                       t.Errorf("int8 enc instructions: expected % x got % x", signedResult, b.Bytes())
                }
        }
 
@@ -182,8 +182,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encUint8, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(unsignedResult, b.Data()) {
-                       t.Errorf("uint8 enc instructions: expected % x got % x", unsignedResult, b.Data())
+               if !bytes.Equal(unsignedResult, b.Bytes()) {
+                       t.Errorf("uint8 enc instructions: expected % x got % x", unsignedResult, b.Bytes())
                }
        }
 
@@ -194,8 +194,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encInt16, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(signedResult, b.Data()) {
-                       t.Errorf("int16 enc instructions: expected % x got % x", signedResult, b.Data())
+               if !bytes.Equal(signedResult, b.Bytes()) {
+                       t.Errorf("int16 enc instructions: expected % x got % x", signedResult, b.Bytes())
                }
        }
 
@@ -206,8 +206,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encUint16, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(unsignedResult, b.Data()) {
-                       t.Errorf("uint16 enc instructions: expected % x got % x", unsignedResult, b.Data())
+               if !bytes.Equal(unsignedResult, b.Bytes()) {
+                       t.Errorf("uint16 enc instructions: expected % x got % x", unsignedResult, b.Bytes())
                }
        }
 
@@ -218,8 +218,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encInt32, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(signedResult, b.Data()) {
-                       t.Errorf("int32 enc instructions: expected % x got % x", signedResult, b.Data())
+               if !bytes.Equal(signedResult, b.Bytes()) {
+                       t.Errorf("int32 enc instructions: expected % x got % x", signedResult, b.Bytes())
                }
        }
 
@@ -230,8 +230,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encUint32, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(unsignedResult, b.Data()) {
-                       t.Errorf("uint32 enc instructions: expected % x got % x", unsignedResult, b.Data())
+               if !bytes.Equal(unsignedResult, b.Bytes()) {
+                       t.Errorf("uint32 enc instructions: expected % x got % x", unsignedResult, b.Bytes())
                }
        }
 
@@ -242,8 +242,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encInt64, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(signedResult, b.Data()) {
-                       t.Errorf("int64 enc instructions: expected % x got % x", signedResult, b.Data())
+               if !bytes.Equal(signedResult, b.Bytes()) {
+                       t.Errorf("int64 enc instructions: expected % x got % x", signedResult, b.Bytes())
                }
        }
 
@@ -254,8 +254,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encUint64, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(unsignedResult, b.Data()) {
-                       t.Errorf("uint64 enc instructions: expected % x got % x", unsignedResult, b.Data())
+               if !bytes.Equal(unsignedResult, b.Bytes()) {
+                       t.Errorf("uint64 enc instructions: expected % x got % x", unsignedResult, b.Bytes())
                }
        }
 
@@ -266,8 +266,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encFloat, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(floatResult, b.Data()) {
-                       t.Errorf("float enc instructions: expected % x got % x", floatResult, b.Data())
+               if !bytes.Equal(floatResult, b.Bytes()) {
+                       t.Errorf("float enc instructions: expected % x got % x", floatResult, b.Bytes())
                }
        }
 
@@ -278,8 +278,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encFloat32, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(floatResult, b.Data()) {
-                       t.Errorf("float32 enc instructions: expected % x got % x", floatResult, b.Data())
+               if !bytes.Equal(floatResult, b.Bytes()) {
+                       t.Errorf("float32 enc instructions: expected % x got % x", floatResult, b.Bytes())
                }
        }
 
@@ -290,8 +290,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encFloat64, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(floatResult, b.Data()) {
-                       t.Errorf("float64 enc instructions: expected % x got % x", floatResult, b.Data())
+               if !bytes.Equal(floatResult, b.Bytes()) {
+                       t.Errorf("float64 enc instructions: expected % x got % x", floatResult, b.Bytes())
                }
        }
 
@@ -302,8 +302,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encUint8Array, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(bytesResult, b.Data()) {
-                       t.Errorf("bytes enc instructions: expected % x got % x", bytesResult, b.Data())
+               if !bytes.Equal(bytesResult, b.Bytes()) {
+                       t.Errorf("bytes enc instructions: expected % x got % x", bytesResult, b.Bytes())
                }
        }
 
@@ -314,8 +314,8 @@ func TestScalarEncInstructions(t *testing.T) {
                instr := &encInstr{ encString, 6, 0, 0 };
                state := newencoderState(b);
                instr.op(instr, state, unsafe.Pointer(&data));
-               if !bytes.Equal(bytesResult, b.Data()) {
-                       t.Errorf("string enc instructions: expected % x got % x", bytesResult, b.Data())
+               if !bytes.Equal(bytesResult, b.Bytes()) {
+                       t.Errorf("string enc instructions: expected % x got % x", bytesResult, b.Bytes())
                }
        }
 }
index 7b7484d3b12c360a96d0165e87da93369c4c2c98..23ec9849f1773225f225c750ce9e2c31fc0509f0 100644 (file)
@@ -43,7 +43,7 @@ func (ctr *Counter) ServeHTTP(c *http.Conn, req *http.Request) {
        case "POST":
                buf := new(bytes.Buffer);
                io.Copy(req.Body, buf);
-               body := string(buf.Data());
+               body := string(buf.Bytes());
                if n, err := strconv.Atoi(body); err != nil {
                        fmt.Fprintf(c, "bad POST: %v\nbody: [%v]\n", err, body);
                } else {
index 4230b031c33d74b765126b8f902447185c604369..78b8320ecaa87a03a8c590f0fed1b13f484d9e6c 100644 (file)
@@ -15,7 +15,7 @@ import (
 func ReadAll(r Reader) ([]byte, os.Error) {
        var buf bytes.Buffer;
        _, err := Copy(r, &buf);
-       return buf.Data(), err;
+       return buf.Bytes(), err;
 }
 
 // ReadFile reads the file named by filename and returns the contents.
index a95d7d215cf3e7bf4a16acc588919b3b89c1b20f..9ebf1a39191e2363e9c329e5baa17393c573d9ce 100644 (file)
@@ -169,7 +169,7 @@ func Quote(s string) string {
        }
        chr[0] = '"';
        b.Write(chr0);
-       return string(b.Data());
+       return string(b.Bytes());
 }
 
 
index c9131607aa19b023100a8dcddfef504662743e28..45e101d88d2b8107423acd021a7f6478a3f67bca 100644 (file)
@@ -326,7 +326,7 @@ func TestForkExec(t *testing.T) {
 
        var b bytes.Buffer;
        io.Copy(r, &b);
-       output := string(b.Data());
+       output := string(b.Bytes());
        expect := "/\n";
        if output != expect {
                t.Errorf("exec /bin/pwd returned %q wanted %q", output, expect);
@@ -605,7 +605,7 @@ func run(t *testing.T, cmd []string) string {
        var b bytes.Buffer;
        io.Copy(r, &b);
        Wait(pid, 0);
-       output := string(b.Data());
+       output := string(b.Bytes());
        if n := len(output); n > 0 && output[n-1] == '\n' {
                output = output[0:n-1];
        }
index b1baf67c793553398a05c15cf1dc3fdb4d4f8be4..1559da23e67120adeb61c4412bb38bee2234c4af 100644 (file)
@@ -883,7 +883,7 @@ func (re *Regexp) ReplaceAllString(src, repl string) string {
        // Copy the unmatched characters after the last match.
        io.WriteString(buf, src[lastMatchEnd:len(src)]);
 
-       return string(buf.Data());
+       return string(buf.Bytes());
 }
 
 // ReplaceAll returns a copy of src in which all matches for the Regexp
@@ -927,7 +927,7 @@ func (re *Regexp) ReplaceAll(src, repl []byte) []byte {
        // Copy the unmatched characters after the last match.
        buf.Write(src[lastMatchEnd:len(src)]);
 
-       return buf.Data();
+       return buf.Bytes();
 }
 
 // QuoteMeta returns a string that quotes all regular expression metacharacters
index d57a1b1938eed50469f3186de4e5e438ec778856..ea98a9e87b1f3cf44975479d7a1107ef04ac449d 100644 (file)
@@ -241,7 +241,7 @@ func (b *Writer) writeLines(pos0 int, line0, line1 int) (int, os.Error) {
                        switch {
                        default: // align left
 
-                               if err := b.write0(b.buf.Data()[pos : pos + c.size]); err != nil {
+                               if err := b.write0(b.buf.Bytes()[pos : pos + c.size]); err != nil {
                                        return pos, err;
                                }
                                pos += c.size;
@@ -258,7 +258,7 @@ func (b *Writer) writeLines(pos0 int, line0, line1 int) (int, os.Error) {
                                                return pos, err;
                                        }
                                }
-                               if err := b.write0(b.buf.Data()[pos : pos + c.size]); err != nil {
+                               if err := b.write0(b.buf.Bytes()[pos : pos + c.size]); err != nil {
                                        return pos, err;
                                }
                                pos += c.size;
@@ -268,7 +268,7 @@ func (b *Writer) writeLines(pos0 int, line0, line1 int) (int, os.Error) {
                if i+1 == b.lines.Len() {
                        // last buffered line - we don't have a newline, so just write
                        // any outstanding buffered data
-                       if err := b.write0(b.buf.Data()[pos : pos + b.cell.size]); err != nil {
+                       if err := b.write0(b.buf.Bytes()[pos : pos + b.cell.size]); err != nil {
                                return pos, err;
                        }
                        pos += b.cell.size;
@@ -339,7 +339,7 @@ func (b *Writer) append(text []byte, updateWidth bool) {
        b.buf.Write(text);
        b.cell.size += len(text);
        if updateWidth {
-               b.cell.width += utf8.RuneCount(b.buf.Data()[b.pos : b.buf.Len()]);
+               b.cell.width += utf8.RuneCount(b.buf.Bytes()[b.pos : b.buf.Len()]);
                b.pos = b.buf.Len();
        }
 }
index 997de4e4a0d533a1b6801e855d6667d8a5d157d9..130a26427ff3dfe2b11bfb152b7d3692bce083c1 100644 (file)
@@ -52,5 +52,5 @@ func HtmlEscape(w io.Writer, s []byte) {
 func HtmlFormatter(w io.Writer, value interface{}, format string) {
        var b bytes.Buffer;
        fmt.Fprint(&b, value);
-       HtmlEscape(w, b.Data());
+       HtmlEscape(w, b.Bytes());
 }
index b96a682c3e49a70012c60c234050a021c12c97e7..d3ce37863af4941404de1e8024688733126bedab 100644 (file)
@@ -314,8 +314,8 @@ func TestAll(t *testing.T) {
                                t.Errorf("expected execute error %q, got %q", test.err, err.String());
                        }
                }
-               if string(buf.Data()) != test.out {
-                       t.Errorf("for %q: expected %q got %q", test.in, test.out, string(buf.Data()));
+               if string(buf.Bytes()) != test.out {
+                       t.Errorf("for %q: expected %q got %q", test.in, test.out, string(buf.Bytes()));
                }
        }
 }
@@ -330,7 +330,7 @@ func TestStringDriverType(t *testing.T) {
        if err != nil {
                t.Error("unexpected execute error:", err)
        }
-       s := string(b.Data());
+       s := string(b.Bytes());
        if s != "template: hello" {
                t.Errorf("failed passing string as data: expected %q got %q", "template: hello", s)
        }
@@ -346,7 +346,7 @@ func TestTwice(t *testing.T) {
        if err != nil {
                t.Error("unexpected parse error:", err)
        }
-       s := string(b.Data());
+       s := string(b.Bytes());
        text := "template: hello";
        if s != text {
                t.Errorf("failed passing string as data: expected %q got %q", text, s);
@@ -355,7 +355,7 @@ func TestTwice(t *testing.T) {
        if err != nil {
                t.Error("unexpected parse error:", err)
        }
-       s = string(b.Data());
+       s = string(b.Bytes());
        text += text;
        if s != text {
                t.Errorf("failed passing string as data: expected %q got %q", text, s);
@@ -388,7 +388,7 @@ func TestCustomDelims(t *testing.T) {
                        }
                        var b bytes.Buffer;
                        err = tmpl.Execute("hello", &b);
-                       s := string(b.Data());
+                       s := string(b.Bytes());
                        if s != "template: hello" + ldelim + rdelim {
                                t.Errorf("failed delim check(%q %q) %q got %q", ldelim, rdelim, text, s)
                        }
@@ -413,7 +413,7 @@ func TestVarIndirection(t *testing.T) {
                t.Fatal("unexpected execute error:", err)
        }
        expect := fmt.Sprintf("%v", &t1);       // output should be hex address of t1
-       if string(buf.Data()) != expect {
-               t.Errorf("for %q: expected %q got %q", input, expect, string(buf.Data()));
+       if string(buf.Bytes()) != expect {
+               t.Errorf("for %q: expected %q got %q", input, expect, string(buf.Bytes()));
        }
 }