The impl.MessageState is embedded in concrete messages only, not in the generated structs that implement a proto message.
It specifically embeds the three pragmas: NoUnkeyedLiterals
, DoNotCompare
, and DoNotCopy
.
The last one, DoNotCopy is a zero-sized array of sync.Mutex
. The sole purpose is to have go vet
complain loudly about shallow copies, as described in the comment:
DoNotCopy can be embedded in a struct to help prevent shallow copies.
This does not rely on a Go language feature, but rather a special case
within the vet checker.
The summary of it all: impl.MessageState
is not supposed to be copied and the mutex is there only to catch copying. If you do so, it is because you are using something the wrong way.