When I use select in Go, how many cases could I listen? Is there an upper limit on it, for example, 10k? Will overmuch cases bring harmful effects?
No, there is no practical upper limit.
I don't believe that there is. However, select
s must be written explicitly at compile-time, so unless you plan on auto-generating the code for that select statement, that sounds painful to write. If you have a big list of channels you need to select over, you should try this instead:
for {
for _, c := range channels {
select {
case val := <-c:
// code...
default:
// code...
}
}
}