by spacey on 12/7/15, 10:57 AM with 79 comments
by alkonaut on 12/7/15, 11:45 AM
Since a concurrent map (aka. Dictionary aka. Hashtable) is a lot more complex and slow than a non concurrent one, it's very very unlikely that Go would ship with its standard map type being a concurrent one. It would be a huge waste.
More likely there is a separate concurrent map type. It's exactly the same in other languages with mutable collections (Java, .NET, C++, ...).
by JulianMorrison on 12/7/15, 12:19 PM
The fixes for this are subtle and annoying. Either you have to lock around your data, make it somehow immutable, or force copying rather than referencing (by making it "value" data).
Go would really benefit from a port of Clojure's data structures.
by kasey_junk on 12/7/15, 11:57 AM
by zalmoxes on 12/7/15, 12:24 PM
by grabcocque on 12/7/15, 11:26 AM
"Getting your locking wrong will corrupt the internal structure of the map."
Ahem.
If you have a non-concurrency-safe map implementation in a language that's advertised as being good for concurrency, there is definitely something wrong.
by khgvljhkb on 12/7/15, 12:37 PM
I recommend Go users to install the boot utility, and playing around with Clojure & core.async. These communities can share many things.
by SixSigma on 12/7/15, 12:36 PM
by vinceyuan on 12/7/15, 12:40 PM
Which types in Go are goroutine safe? Do we need to use sync.Mutex for all global variables which are read and written in goroutines? My understanding is only read-only variables are goroutine safe.