I found this <-(chan string)(nil)
strange construct in the Gobetween sources.
- Is it just a fancy way to block forever or it has some kind of advantage over
select{}
? - How to parse this statement?
I found this <-(chan string)(nil)
strange construct in the Gobetween sources.
select{}
?The statement casts nil
as type chan string
, then reads from it.
According to Dave Cheney's Channel Axioms:
A receive from a nil channel blocks forever