Direction

The syntax for sending and receiving data from a channel is provided below:


data := <- a // read content from channel a 
a <- data // write on channel a  
                        

The direction of the arrow relative to the channel specifies whether data is sent or received.

Sends and receives on a channel are blocked by default. What this means? When data is sent to a channel, control is locked on the send statement until some other Goroutine reads from that channel. channel.

Likewise, when data is read from a channel, the read is blocked until some Goroutine writes data to that channel.

channel_direction.go
Channels