pointer vs value receiver methods on a struct with a mutex
I have a struct with a sync.Mutex and a method with a value receiver that increments a counter under the lock. go vet warns: 'passes lock by value'. I copied it on purpose thinking it was fine since the mutex protects the counter. What's actually wrong here? I copied it on purpose thinking the mutex made that safe, so I'm clearly missing something about how copies interact.
4 replies