4 ms·
Only if you do something like: ml.Lock() v := m["key"] // maybe m is something like map[string]*MyValue ml.Unlock() v.foo = "bar" // m["key"].f
by nemothekid 11y ago
Only if you do something like:
ml.Lock()
v := m["key"] // maybe m is something like map[string]*MyValue
ml.Unlock()
v.foo = "bar" // m["key"].foo is now bar, because m["key"] both point to the same object
- Strom 11y agoIf you ever intend to read that v.foo value in another goroutine, then that edit needs to be before freeing the lock as well.