func gentor(done <-chan struct{}) <-chan interface{} {
genC := make(chan interface{})
go func() {
for {
select {
case <-done:
return
case genC <- rand.Intn(10000):
time.Sleep(time.Second * 1)
}
}
}()
return genC
}
网友评论