reading from a file, passing each row to another goroutine through a channel, and that second goroutine does something to those input data and passes them again to another third goroutine. Assuming the order of data passing matters, how can we have multiple goroutines in the second stage reading from the channel?
As you may know, we can't guarantee the order of execution when we use goroutines and channels. This is an issue here. How can we have multiple concurrent goroutines reading from a channel and still guarantee the order of the output?
You could implement sth like a tee channel where multiple goroutines are reading from a single source,
sending the data downstream means you going to lose the ordering so maybe this is not a good idea
The reading part is ok. My issue is writing to the output with the same order that it came through
Обсуждают сегодня