From a74ae952826fd65006a8190c50bbbee4c4869cf9 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Mon, 19 May 2025 13:05:24 -0400 Subject: strings,bytes: add internal docs about perennial noCopy questions Updates #26462 Updates #25907 Updates #47276 Updates #48398 Change-Id: Ic64fc8d0c284f6e5aa383a8d417fa5768dcd7925 Reviewed-on: https://go-review.googlesource.com/c/go/+/674096 Auto-Submit: Alan Donovan LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Knyszek --- src/bytes/buffer.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/bytes/buffer.go') diff --git a/src/bytes/buffer.go b/src/bytes/buffer.go index f90d9eca0f..9684513942 100644 --- a/src/bytes/buffer.go +++ b/src/bytes/buffer.go @@ -21,6 +21,12 @@ type Buffer struct { buf []byte // contents are the bytes buf[off : len(buf)] off int // read at &buf[off], write at &buf[len(buf)] lastRead readOp // last read operation, so that Unread* can work correctly. + + // Copying and modifying a non-zero Buffer is prone to error, + // but we cannot employ the noCopy trick used by WaitGroup and Mutex, + // which causes vet's copylocks checker to report misuse, as vet + // cannot reliably distinguish the zero and non-zero cases. + // See #26462, #25907, #47276, #48398 for history. } // The readOp constants describe the last action performed on -- cgit v1.3