通道方向
https://gobyexample-cn.github.io/channel-directions
当使用通道作为函数的参数时,你可以指定这个通道 “只读” 或 ”只写“
只写:chan<-
go
func ping(pings chan<- string, msg string) {
pings <- msg
}只读:<-chan
go
func pong(pings <-chan string, pongs chan<- string) {
msg := <-pings
pongs <- msg
}