On Wed, Jul 25, 2012 at 6:49 AM, N. Riesco - GMail
<
nicolas...@gmail.com> wrote:
> I'm going to try to answer my own question:
What are the problem that you are trying to solve?
A closed channel means something and a empty channel means another thing.
Closed channel: You can be sure that, starting now, this channel will
not return any value.
Empty channel: You can be sure that, until now, nobody is sending
nothing in this channel, but keep waiting and you could get some
value.
You use the ok idiom to detect if a channel is closed or not, if you
want to know if a channel is empty the select statement.
Using len/cap for channel isn't safe because a len followed by a
reading/writing isn't atomic and things could change from one call to
another (like zeebo) said.