chan channel直译过来就是管道,chan关键字定义了goroutine中的管道通信,一个goroutine可以和另一个goroutine进行通信。 chan的读写和定义如下: //define a chan type variable var ch chan int = make(chan int, 10); //or ch := make(chan int, 10); //write data into chan ch <- 1; ch <- 2; //read data from chan var x int; x = <-ch; x = <-ch;