It can, in theory, but it gets incredibly unlikely very very quickly. For example, if you'd have 100 goroutines reading from a channel and you write 100 values to it, the chances of one particular goroutine to read is around 63%. If you write 1000, the chance is 99.996%. So as long as the ratio of values written to reading goroutines is adequate, you shouldn't need to worry about it.
But, very likely, you don't want to have the correctness of your program to depend on that behavior. On Mon, Aug 22, 2016 at 12:13 AM, Steven Hartland <ste...@multiplay.co.uk> wrote: > On 21/08/2016 21:51, Jan Mercl wrote: > > On Sun, Aug 21, 2016, 22:43 Steven Hartland <ste...@multiplay.co.uk> > wrote: > >> If I have multiple goroutines reading from a channel are they guaranteed >> to be FIFO i.e. is the handler that requested the read first guaranteed to >> get the first value, second to get the second and so on? >> >> Values read from a channel will always be in the FIFO order, but that is > not related to concurrent channel reads as those are, per se, not ordered > in any way. > > So can this result in one routine never getting any reads if there's a > constant flow of incoming readers? > > Regards > Steve > > -- > 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.