That's the old way. Now a channel receive always blocks. The "ok"
value is false if a zero value was received because the channel is
closed.
To do a non-blocking channel read today you need to write
select {
case v = <-ch:
// Do something with v.
default:
}
The OP probably wants to check both channels in a single select
statement.
Ian
Andrew Gerrand <a...@golang.org> writes:> You can do a non-blocking channel read like so:
>
> v, ok := <-ch
>
> "ok" is a boolean that indicates whether a receive occurred.That's the old way. Now a channel receive always blocks. The "ok"
value is false if a zero value was received because the channel is
closed.