Channels

This lesson explains in detail the workings of channels in Go

We'll cover the following...

About channels

Channels are pipes through which you can send and receive values using the channel operator, <-.

ch <- v // Send v to channel ch.
v := <-ch // Receive from ch, and
// assign value to v.

(The data flows in the direction of the arrow.)

Like maps and slices, channels must be created before use:

ch := make(chan int)

By default, sends and receives block wait until the other side is ready. This ...