go并发学习
loop: break后,跳出selctor,然后跳到loop到最后end。
Loop:
for {
select {
case v, ok := <-intChan:
if !ok {
break Loop
}
ts1 = time.Now().Unix()
if ts0 == 0 {
fmt.Println("Received:", v)
} else {
fmt.Printf("Received: %d [interval: %d s]\n", v, ts1-ts0)
}
}
ts0 = time.Now().Unix()
time.Sleep(receptionInterval)
}
fmt.Println("End.")
}
---当才华撑不起你的野心的时候,请努力!---跑起来。