[go-nuts] bytes.NewBuffer(make([]byte, 0, )) allocates 4096 bytes buffer

2020-06-11 Thread Gautam Saha
Trying to allocate an in-memory buff of small size (few bytes) using bytes.NewBuffer(make([]byte, 0, )) The allocated buffer has size 4096 bytes i.e. > than what I requested for. Why is this so? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.

Re: [go-nuts] bytes.NewBuffer(make([]byte, 0, )) allocates 4096 bytes buffer

2020-06-12 Thread Gautam Saha
Probably I was doing something wrong. @Brian your snippet works as I would have expected. On Friday, 12 June 2020 15:43:14 UTC+5:30, Brian Candler wrote: > > 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