Channels#
A channel carries values between goroutines. chan T is
bidirectional; chan<- T is send-only; <-chan T is
receive-only.
Create a buffered channel.
ch := make(chan int, 1) // buffered, cap 1
Send.
ch <- 42
Receive.
v := <-ch
See Concurrency for the full coordination surface
(select, close, range over channels).
References#
Concurrency for goroutines,
select, and the channel idioms.Control flow for the
selectstatement.