|
|
|
|
|
by somekyle
1664 days ago
|
|
Yes, overapplying directional advice is a problem, and channels aren't always the right choice, but mutexes/cond vars/atomics have always been part of Go and they've always been listed as viable options, just not usually the best choice for high level coordination.
To quote the go1 Effective Go on channel-based interaction: This approach can be taken too far. Reference counts may be best done
by putting a mutex around an integer variable, for instance.
But as a high-level approach, using channels to control access makes it easier
to write clear, correct programs.
I'm sure somebody has been banging a "Go programs should never use mutexes" drum, but it hasn't ever been the position of the Go team that channels are a panacea or that mutexes _shouldn't_ be used, as far as I've ever seen. |
|