4096 bytes is typically a page, so maybe something is going on to do with allocation on page boundaries, but need to see your code.
Jan Mercl
unread,
Jun 11, 2020, 1:25:39 PM6/11/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Gautam Saha, golang-nuts
Nowhere the docs say one can control the buffer size. Instead, the
passed []byte is documented to be used "as its initial contents", not
"as its initial buffer".
Brian Candler
unread,
Jun 12, 2020, 6:13:14 AM6/12/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
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?
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.
Gautam Saha
unread,
Jun 12, 2020, 9:45:47 AM6/12/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Probably I was doing something wrong. @Brian your snippet works as I would have expected.