0

Say, I have an array of buffered input channels. I want to read a value from a channel, preferring those channels that come earlier in the array, and I'd like to know which channel the value has come from. If all the channels are empty, I want to block and wait. However, once all the channels are closed, I'd also like to unblock and detect that.

How should I implement it in code?

Something like:

func waitValueArrives(channels [] chan interface{}) (interface{}, int) {
...
}
Roman Maltsev
  • 307
  • 1
  • 3
  • 9

0 Answers0