While working and generating protobuf stubs in go I stumbled upon this interesting issue.
Whenever I try and copy a message's struct by value I get this warning:
call of state.world.script.HandleEvent copies lock value: throne/server/messages.PlayerDialogeStatus contains google.golang.org/protobuf/internal/impl.MessageState contains sync.Mutex copylocks
While I understand why copying a mutex lock by value is wrong, I started wondering why are they even there in the first place.
And thus my question: Why does the go generated protobuf files contain mutex locks placed on the message structs, specifically on the MessageState
struct?
Or alternatively: What is the goal of the mutex lock placed in the MessageState
struct found on generated protobuf message structs?