select statement chooses which of a set of possible
receive operations will proceed. It looks similar to a
switch statement but with all the cases referring to communication operations. A
select blocks until one of its cases can run, then it executes that case. It chooses one at random if multiple are ready.
main function calls the
fibonacci function with two unbuffered channels, one for results and one for a
quit signal. The
fibonacci function uses a
select statement to wait on both channels. The anonymous, asynchronous
go function that starts at line 21 waits to receive values at line 23, then prints them. After 10 values, it sets the
quit channel, so the
fibonacci function knows to stop.