Folks, well, subj - why can't I "just" do a select on a slice of channels? Yes, I can run a bunch goroutines with of reads on an each channel, funnel it all into 1 notification channel, pick up on the other side... boring stuff, really...
But why not "just" func main() { cc := make([]chan interface{}, 10) for i := 0; i < len(cc); i++ { cc[i] = make(chan interface{}) } dd := make([]chan int) for i := 0; i < 1000; i++ { dd = append(dd, make(chan int)) } select { // do we need a special <-[] ? case i, c, v, ok := <-[]cc: fmt.Printf("cc replied : channel index %d, channel %v, value %v, ok=%v", i, c, v, ok) // or I dunno, not introducing a new op case i, d, v, ok := <-dd: fmt.Printf("dd sent something: channel index %d, channel %v, value %v, ok=%v", i, d, v, ok) } // or shorter, but I hope you get the drift select { case i, c, ok := <-[]cc: fmt.Printf("cc replied : channel index %d, channel %v, value %v, ok=%v", i, c, <-c, ok) case i, d, ok := <-dd: fmt.Printf("dd sent something: channel index %d, channel %v, value %v, ok=%v", i, d, <-d, ok) } } Why? System limitations? Rarely needed? Feels like extending language to handle that would not be too much of violation of an existing code. Ok, lets go nuts! Mirrored "cc <- value" for sending to a slice of channels! -- it should pick randomly available channel out of the slice of channels! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/6d9d8c38-4183-4299-ac60-629ab13c100a%40googlegroups.com.