summaryrefslogtreecommitdiff
path: root/src/pkg/bytes/buffer.go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-09-13 11:59:49 +0200
committerOndřej Surý <ondrej@sury.org>2011-09-13 12:08:04 +0200
commit3d8cc67ce421c3eaf15808935689abcd908af51f (patch)
tree0f145ecea21fa862c882a6c8efed5baf43f7f0a7 /src/pkg/bytes/buffer.go
parentc00ace2663030a0cbe09f8854a7b3f4a7d60374d (diff)
downloadgolang-3d8cc67ce421c3eaf15808935689abcd908af51f.tar.gz
Read goinstall dashboard option from debian configuration file
Diffstat (limited to 'src/pkg/bytes/buffer.go')
-rw-r--r--src/pkg/bytes/buffer.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/pkg/bytes/buffer.go b/src/pkg/bytes/buffer.go
index 5de86105d..975031bfa 100644
--- a/src/pkg/bytes/buffer.go
+++ b/src/pkg/bytes/buffer.go
@@ -336,13 +336,18 @@ func (b *Buffer) ReadString(delim byte) (line string, err os.Error) {
// NewBuffer creates and initializes a new Buffer using buf as its initial
// contents. It is intended to prepare a Buffer to read existing data. It
-// can also be used to size the internal buffer for writing. To do that,
+// can also be used to size the internal buffer for writing. To do that,
// buf should have the desired capacity but a length of zero.
+//
+// In most cases, new(Buffer) (or just declaring a Buffer variable) is
+// preferable to NewBuffer. In particular, passing a non-empty buf to
+// NewBuffer and then writing to the Buffer will overwrite buf, not append to
+// it.
func NewBuffer(buf []byte) *Buffer { return &Buffer{buf: buf} }
// NewBufferString creates and initializes a new Buffer using string s as its
// initial contents. It is intended to prepare a buffer to read an existing
-// string.
+// string. See the warnings about NewBuffer; similar issues apply here.
func NewBufferString(s string) *Buffer {
return &Buffer{buf: []byte(s)}
}