|
|
|
|
|
by hierro
4431 days ago
|
|
You're right, the example does have a glaring bug - and I completely agree with you, examples should not include incorrect code. Just to clarify, maps can be read concurrently without locking as long as you're not writing to them. As soon as any concurrent operation might make changes to the map (as the example does) you need locking, preferably a sync.RWMutex (a sync.Mutex will also work but will be way less efficient for no good reason). |
|