[go-nuts] Re: Channels: selecting the last element

2018-12-18 Thread john_halderman
This code works though, it's not possible to send the dc before the rc is read and so the done counter cannot reach 2 before both 0s have been written. I made a playground that runs it 100k times to demonstrate. https://play.golang.org/p/DKltfzDI95L On Tuesday, December 18, 2018 at 8:35:26 AM U

Re: [go-nuts] Re: Channels: selecting the last element

2018-12-18 Thread Robert Engels
I don’t think that code is correct. You are using buffered channels do it could read the done values and exit before reading any results technically since when data is available on both it is random which is read. > On Dec 18, 2018, at 8:32 AM, john_halder...@moma.org wrote: > > This code work

Re: [go-nuts] Re: Channels: selecting the last element

2018-12-18 Thread Halderman, John
You are both correct, I somehow missed that they were buffered. Thanks for correcting me. On a side note, is there a reason not to use a wait all? Thanks. On Tue, Dec 18, 2018 at 10:05 AM Robert Engels wrote: > I don’t think that code is correct. You are using buffered channels do it > could rea