4 ms·
I don't really think what I suggest goes against the article you link to. It basically says: use channels when appropriate, but sometimes the best approach is t
by amix 13y ago
I don't really think what I suggest goes against the article you link to. It basically says: use channels when appropriate, but sometimes the best approach is to use locks.
E.g. An bank account is shared state (similar to a reference count) and the best approach is to put a mutex around it instead of fighting with channel synchronization.
- xkarga00 13y agoThere are no implications here, it's stated pretty explicitly: "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." There is a difference between what someone with a background from other mainstream programming languages might think would be the best approach to locking (mutexes) and the idiomatic Go approach (unbuffered channels).