channel is written, the channel must be closed, otherwise there will be a deadlock in range traversal. Is this correct?
so what if I have a scenario in which one goroutine writes data to the channel and one or more goroutine reads data from the channel without closing the channel?
< hr >add:
my question is a little unclear. Writing to the channel is an endless cycle of continuous writing, and reading is also constant reading, so how do you close the channel? At present, I open a goroutine to continue to write, open 5 goroutine to read with range, there is no problem, but there is such a sentence in reading, so ask.
this channel is constantly writing data, so there is no "channel after writing", so it cannot be closed, so the other goroutine can just read the data by range. , the question is changed to this, do you understand it correctly? at present, the program has not been reported wrong, just ask if it is standardized to write in this way.