Channels

Channels can be considered tubes through which Goroutines communicate.

Similar to how water flows from one end of a pipe to the other, data can be sent from one end and received from the other end using channels.

Each channel has a type associated with it. This type is the type of data the channel is allowed to carry. No other types can be transported using the channel.

The zero value of a channel is nil. Null channels are of no use, so the channel must be defined using make, similar to maps and slice.


channel := make(chan int) // carries data of type int
                        
channels.go