In Go, if the channel channel closed, I can still read from it using the following syntax, and I can check if it is closed.
value, ok := <- channel if !ok {
However, if I do not know if the channel is closed and I am writing it blindly, I may get an error. I want to know if there is a way to check the channel and write to it only when it is not closed. I ask this question because sometimes I do not know if the channel is closed or not in the program.
source share