2 ms·
A channel may be closed with the built-in function close; the multi-valued assignment form of the receive operator tests whether a channel has been closed. [1
by shurcooL 13y ago
A channel may be closed with the built-in function close; the multi-valued
assignment form of the receive operator tests whether a channel has been closed. [1]
Given that is available, why is the use of a separate bool quit channel preferred?
[1] http://golang.org/ref/spec#Channel_types http://golang.org/ref/spec#Channel_types
- dragonwriter 13y agoA quit channel (that is not receive only) can be used to send back a quit message by a goroutine that only has a receive-only view of the main data channel; close() can't be called on a receive-only channel.
- frou_dh 13y agoIn the link, the quit is acknowledged, so one side closing the channel straight off the bat wouldn't allow for that.