October 2015
Beginner to intermediate
400 pages
14h 44m
English
If goroutines are the activities of a concurrent Go program,
channels are the connections between them.
A channel is a communication mechanism that lets one goroutine send
values to another goroutine.
Each channel is a conduit for values of a particular type, called the
channel’s element type.
The type of a channel whose elements have type int is written
chan int.
To create a channel, we use the built-in make function:
ch := make(chan int) // ch has type 'chan int'
As with maps, a channel is a reference to the data structure
created by make.
When we copy a channel or pass
one as an argument to a function, we are copying a reference, so
caller and callee refer to the same data structure.
As with ...