goroutine运行在相同的地址空间,因此访问共享内存必须 做好同步。goroutine奉行通过通信来共享内存,而不是共享内存通信
它跟map一样,使用make来创建,它是一个引用 ,而不是值传递
make(chan Type, capacity)
channel <- value //发送value到channel
<- channel //接收并将其丢弃
x := <-channel //从channel中接收数据,并赋值给x
x, ok := <-channel //功能同上,同时检查通道是否已关闭或者是否为空
原文:https://www.cnblogs.com/baylorqu/p/9672786.html