I'm learning about goroutines and channels and have a question about what happens if multiple goroutines try fetching data from the same channel.
How does the go runtime makes sure that data in a channel that is being read by multiple goroutines is provided to only one of the goroutines waiting on the channel and not duplicated or sent to multiple goroutines.
Does the go runtime prevent race conditions when there are multiple goroutines trying to fetch data from the exact same channel? Is there some kind of ordering as to which of the waiting goroutines is given the data for instance First Come First Served?
question from:https://stackoverflow.com/questions/65832949/data-duplication-by-multiple-goroutines