Re:Uber Go Style Guide
by Strom on Friday October 11, 2019 @06:10PM
(#21228947)
This issue comes up with a reused bytes.Buffer.
Yes the documentation for .Bytes() says that "The slice is valid for use only until the next buffer modification" but people don't always read the docs for every method they use, especially if it's a method they've used a bunch before. Having a reusable buffer that you return the .Bytes() value from is very tempting. Bug-free code would either copy the result or not reuse the buffer.
[ Parent
| on HN ]
There are no comments on this comment yet.