https://talks.golang.org/2013/advconc.slide#5
It's easy to go, but how to stop?
Long-lived programs need to clean up.
Let's look at how to write programs that handle communication, periodic events, and cancellation.
The core is Go's select
statement: like a switch
, but the decision is made based on the ability to communicate.
select { case xc <- x: // sent x on xc case y := <-yc: // received y from yc }