From 53b2b64b649b26c7bb3397bec5d86d3b203eb015 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Fri, 15 Nov 2024 19:22:16 +0000 Subject: sync: add explicit noCopy fields to Map, Mutex, and Once Following CLs will refactor Mutex and change the internals of Map. This ends up breaking tests in x/tools for the copylock vet check, because the error message changes. Let's insulate ourselves from such things permanently by adding an explicit noCopy field. We'll update the vet check to accept that as the problem, rather than depend on less explicit internals. We capture Once here too to clean up the error message as well. Change-Id: Iead985fc8ec9ef3ea5ff615f26dde17bb03aeadb Reviewed-on: https://go-review.googlesource.com/c/go/+/627777 Reviewed-by: Cherry Mui LUCI-TryBot-Result: Go LUCI Auto-Submit: Michael Knyszek Reviewed-by: Tim King --- src/sync/map.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/sync/map.go') diff --git a/src/sync/map.go b/src/sync/map.go index 33bc8141ab..4f1395110a 100644 --- a/src/sync/map.go +++ b/src/sync/map.go @@ -36,6 +36,8 @@ import ( // // [the Go memory model]: https://go.dev/ref/mem type Map struct { + _ noCopy + mu Mutex // read contains the portion of the map's contents that are safe for -- cgit v1.3-5-g9baa