-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of []byte in sync.Pool #1578
Comments
ah TIL. Care to make the PR too? |
I looked into this and I'm concerned that the existing use of pooling is buggy. If a user uses a custom With regards to fixing the issue, I'm not sure it's going to be possible to do without breaking changes, since we'd need |
Documentation issue then? (And a thing to turn off pooling?) |
Yeah, sounds like there's not much to do except warn users about the risks of using a custom Reader. |
care to work your thoughts into a documentation PR then? |
Hi!
staticcheck
flags the use ofsync.Pool
inserver.go
as incorrect, as it's passing[]byte
instead of*[]byte
, which means every instance ends up allocating a slice header. See https://staticcheck.dev/docs/checks/#SA6002 and https://go-review.googlesource.com/c/go/+/24371 for more information, discussion and examples.To fix it, I suggest changing instances of
Put
to pass a reference to the slice, and to ensure that the same alloc that was got is put back.The text was updated successfully, but these errors were encountered: