How Go's vet catches copies of sync.Mutex and noCopy
How Go detects struct copies with sync.noCopy

Go's sync package uses a zero-size noCopy marker to prevent copying types like sync.Mutex and sync.Map. The marker works with go vet's copylocks checker, which flags copies of types that implement sync.Locker only via pointer. The checker recursively inspects struct fields, so even types that embed noCopy indirectly are caught. This article explains the mechanism, why noCopy has Lock and Unlock methods, and how to add the marker to your own types. It also covers edge cases like sync.RWMutex and the impact of field placement on struct size.
The marker still cannot stop the compiler from copying a value.