Skip to content
Ricky
English

Search

Searching… No matching pages. Matching pages are listed below. Search is unavailable. Please try again.

15 Rules of Channels and Their Implementation

  • Ricky Lin
  • 1 minute
On this page

Operation rules

OperationnilClosed channelOpen buffered channelOpen unbuffered channel
ClosepanicpanicClose succeeds; buffered values can be read. After buffer drains, further reads return the zero value of the channel type.Close succeeds; further reads return the zero value of the channel type.
ReceiveBlockNon-blocking; returns the zero value of the channel typeNon-blocking; reads values normallyBlock
SendBlockpanicNon-blocking; writes values normallyBlock

Compile-time rules

OperationChannel typeResult
ReceiveSend-only channelCompile error
SendReceive-only channelCompile error
CloseReceive-only channelCompile error