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> 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.
> For more options, visit 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.

Reply via email to