However, it does say "The new Buffer takes ownership of buf" - why would it 
do that if it were allocating a new buffer and taking a copy of the 
original?

The code has the answer, it's just a single line:
https://golang.org/src/bytes/buffer.go?s=14279:14313#L440

func NewBuffer(buf []byte) *Buffer { return &Buffer{buf: buf} }


ISTM that the Buffer object is simply using the buf you provided.  I don't 
understand where the claim comes from that (a) it allocates a buffer, and 
(b) the allocated buffer is of size 4096 bytes.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/8b8ca391-7fd2-4c55-94c1-44516a4cbfaao%40googlegroups.com.

Reply via email to