bytes: note that NewBuffer take ownership of its argument

Fixes #19383

Change-Id: Ic84517053ced7794006f6fc65e6f249e97d6cf35
Reviewed-on: https://go-review.googlesource.com/44691
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Alberto Donizetti 2017-06-02 17:07:33 +02:00
parent c82a6307f4
commit 29469d2406

View file

@ -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.