Interesting suggestion, but I added the implementation with buffer = 1 here and it still deadlocks: https://github.com/egonk/chandemo/blob/master/2_3.go#L5
It stopped deadlocking when buffer = 5, so I think it will be a nice lesson about hiding design problems with buffers. Did you have something else in mind? I've also simplified the correct solution and it looks like this now: https://github.com/egonk/chandemo/blob/master/2_4.go (not that bad, but still somewhat tricky async approach) On Monday, December 9, 2019 at 1:55:08 PM UTC+1, luka...@gmail.com wrote: > > You can do it without a goroutine as long as the channel has at least one > buffer slot so execution passes to the select and uses the data. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/7a9e1e1d-a8f2-4e33-aea9-6bc7b23bea8e%40googlegroups.com.