5 ms·
"Do not communicate by sharing memory; instead, share memory by communicating." - https://go.dev/blog/codelab-share https://go.dev/blog/codelab-share Wait grou
by YZF 2y ago
"Do not communicate by sharing memory; instead, share memory by communicating." - https://go.dev/blog/codelab-share https://go.dev/blog/codelab-share
Wait groups are preferred to channels for the purposes they serve. Mostly waiting for goroutines to finish. You can use a channel but wait groups are much cleaner.
Mutexes for shared memory are less preferred than channels. There are always exceptions.
But yeah, if all you have is a hammer then everything looks like a nail. Go has mutexes and wait groups and channels and all of these have their right place and use case. If you're using mutexes to effectively re-implement what channels support then you're doing it wrong. If you're using channels for something that can be a function call then you're also doing it wrong. Software is hard.