What can Go chan do that a list cannot?
- by alpav
I want to know in which situation Go chan makes code much simpler than using list or queue or array that is usually available in all languages.
As it was stated by Rob Pike in one of his speeches about Go lexer, Go channels help to organize data flow between structures that are not homomorphic.
I am interested in a simple Go code sample with chan that becomes MUCH more complicated in another language (for example C#) where chan is not available.
I am not interested in samples that use chan just to increase performance by avoiding waiting of data between generating list and consuming the list (which can be solved by chunking) or as a way to organize thread safe queue or thread-safe communication (which can be easily solved by locking primitives).
I am interested in a sample that makes code simpler structurally disregarding size of data.
If such sample does not exist then sample where size of data matters.
I guess desired sample would contain bi-directional communication between generator and consumer.
Also if someone could add tag [channel] to the list of available tags, that would be great.