I don’t think that is correct. If the channels provide sorted async data - you need to have a value available at every channel in order to produce a sorted merged.
The consumer needs to wait until every channel has supplied a value. Otherwise - imagine 2 channels A,B. A provides 5, B has not provided anything, so you process 5, then B provides 3, oops - out of order… > On Oct 21, 2018, at 1:26 PM, roger peppe <rogpe...@gmail.com> wrote: > > Channels can work fine for this kind of thing. > > The easiest (but probably a little less efficient) way is to write a function > that knows how to merge two channels, then use n-1 of them to merge n > channels. Whenever you don't currently have a value from a channel, read one, > then output the smallest of the two values that you have. > > Alternatively read a value from all channels, then output smallest (you could > use a binary heap if n might be large), and read from that value's channel > again. > > > On Sun, 21 Oct 2018, 7:53 am Tamás Gulácsi, <tgulacs...@gmail.com > <mailto:tgulacs...@gmail.com>> wrote: > Do you really want to use channels for this? You can't predict the selection > order and can't peek into a channel, so you have N random source... > > -- > 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 > <mailto:golang-nuts%2bunsubscr...@googlegroups.com>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > -- > 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 > <mailto:golang-nuts+unsubscr...@googlegroups.com>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- 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. For more options, visit https://groups.google.com/d/optout.