diff options
author | Rob Pike <r@golang.org> | 2009-09-16 15:15:00 -0700 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2009-09-16 15:15:00 -0700 |
commit | 111276355791f987f8afa11068acec498380b1ea (patch) | |
tree | f4bb2f73b77370ff44385ccc9ff25cff6fd80319 /src/pkg/bytes/buffer.go | |
parent | 85d73f1a45411a025eb602c73ae9be96461f3e42 (diff) | |
download | golang-111276355791f987f8afa11068acec498380b1ea.tar.gz |
rename bytes.Buffer.Data() to bytes.Buffer.Bytes()
R=rsc
DELTA=152 (6 added, 0 deleted, 146 changed)
OCL=34695
CL=34701
Diffstat (limited to 'src/pkg/bytes/buffer.go')
-rw-r--r-- | src/pkg/bytes/buffer.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/pkg/bytes/buffer.go b/src/pkg/bytes/buffer.go index 6c857069b..fbaa93757 100644 --- a/src/pkg/bytes/buffer.go +++ b/src/pkg/bytes/buffer.go @@ -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 } |