3 ms·
>This is something I don't quite understand about the Go community: why are people fine with using Mutex everywhere? The default approach in Go is to use chann
by kgeist 4y ago
>This is something I don't quite understand about the Go community: why are people fine with using Mutex everywhere?
The default approach in Go is to use channels. The preferred idiom is "share by communicating". I think mutexes are overused by people who came from other languages and who aren't accustomed to channels yet. They spawn goroutines which communicate by sharing when it should be the other away around - no shared state with a few exceptions. I think there's no proliferation of synchronization primitives in Go because sharing state is considered a bad practice.
- hintymad 4y agoGot it. I saw ReMutex used on maps, for instance, the other day. What if one needs to have shared data, say, a routing table for all incoming requests?