1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| package main import ( "time" ) func main() { ch := make(chan int, 10) go func() { var i = 1 for { i++ ch <- i } }() for { select { case x := <- ch: println(x) case <- time.After(3 * time.Minute): println(time.Now().Unix()) } } }
|