I have two goroutines independently producing data, each sending it to a channel. In my main goroutine, I\'d like to consume each of these outputs as they come in, but don\'t ca
Close is nice in some situations, but not all. I wouldn't use it here. Instead I would just use a done channel:
for n := 2; n > 0; {
select {
case p := <-mins:
fmt.Println("Min:", p) //consume output
case p := <-maxs:
fmt.Println("Max:", p) //consume output
case <-done:
n--
}
}
Complete working example at the playground: http://play.golang.org/p/Cqd3lg435y