diff options
| author | 2026-02-22 09:51:18 +0800 | |
|---|---|---|
| committer | 2026-02-22 09:51:18 +0800 | |
| commit | 36ca8828cb5fb76a2a9b6c821f7d7ca18e9e83bc (patch) | |
| tree | c30cfb7b48ebca730053ba9d5ff4c6c224606689 /internal/bufpool | |
| parent | repository: Modernize b.N/b.Loop usage (diff) | |
| signature | No signature | |
bufpool: Document how .Bytes is intended to be used
Diffstat (limited to 'internal/bufpool')
| -rw-r--r-- | internal/bufpool/buffers.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/internal/bufpool/buffers.go b/internal/bufpool/buffers.go index 19e3f80a..cb86b17e 100644 --- a/internal/bufpool/buffers.go +++ b/internal/bufpool/buffers.go @@ -25,6 +25,12 @@ const ( // Buffers must not be copied after first use; doing so can cause double-returns // to the pool and data races. // +// In general, pass Buffer around when used internally, and directly .Bytes() when +// returning output across our API boundary. It is neither necessary nor efficient +// to copy/append the .Bytes() to a newly-allocated slice; in cases where we do +// want the raw byte slice out of our API boundary, it is perfectly acceptable to +// simply not call Release(). +// //go:nocopy type Buffer struct { _ struct{} // for nocopy |
