Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumGosync.Mutex and RWMutexSingle-choice MCQ

What is the behavior of this code that copies a struct containing a sync.Mutex?

type Counter struct { mu sync.Mutex n int } func (c Counter) Inc() { // value receiver c.mu.Lock() defer c.mu.Unlock() c.n++ }