go tutorial select statement
问题 I'm working through the examples at tour.golang.org, and I've encountered this code I don't really understand: package main import "fmt" func fibonacci(c, quit chan int) { x, y := 0, 1 for { select { case c <- x: // case: send x to channel c? x, y = y, x+y case <-quit: // case: receive from channel quit? fmt.Println("quit") return } } } func main() { c := make(chan int) quit := make(chan int) go func() { // when does this get called? for i := 0; i < 10; i++ { fmt.Println(<-c) } quit <- 0 }()