package main
import("fmt""time")//管道 channel,向管道发送数据funcsend_channel(ch chanint, begin int){
for i := begin; i < begin+10; i++{
ch <- i //向管道发送数据}}funcmain(){
fmt.Printf("Main running...\n")
channelV1 :=make(chanint)
channelV2 :=make(chanint)gosend_channel(channelV1,0)gosend_channel(channelV2,10)
time.Sleep(time.Second)for{
select{
case val :=<-channelV1://接收管道的数据
fmt.Printf("get value %d from channel_v1.\n",val)case val :=<-channelV2:
fmt.Printf("get value %d from channel_v2.\n",val)case<-time.After(2*time.Second):
fmt.Printf("Time out.")return}}}