Commit 29469d24 authored by Alberto Donizetti's avatar Alberto Donizetti

bytes: note that NewBuffer take ownership of its argument

Fixes #19383

Change-Id: Ic84517053ced7794006f6fc65e6f249e97d6cf35
Reviewed-on: https://go-review.googlesource.com/44691Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent c82a6307
...@@ -441,10 +441,12 @@ func (b *Buffer) ReadString(delim byte) (line string, err error) { ...@@ -441,10 +441,12 @@ func (b *Buffer) ReadString(delim byte) (line string, err error) {
return string(slice), err return string(slice), err
} }
// NewBuffer creates and initializes a new Buffer using buf as its initial // NewBuffer creates and initializes a new Buffer using buf as its
// contents. It is intended to prepare a Buffer to read existing data. It // initial contents. The new Buffer takes ownership of buf, and the
// can also be used to size the internal buffer for writing. To do that, // caller should not use buf after this call. NewBuffer is intended to
// buf should have the desired capacity but a length of zero. // prepare a Buffer to read existing data. It 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 // In most cases, new(Buffer) (or just declaring a Buffer variable) is
// sufficient to initialize a Buffer. // sufficient to initialize a Buffer.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment