some value?
I don’t want to block the channel. I just want to see if some value is coming in.
If yes then I’ll receive (block) and get it. Otherwise I’ll send a value to it; signalling that some other goroutine is done.
I’ve tried using select for this but I think I’m using it wrong.
Trying two sync two goroutines here. Want to show progress of A if B is done first to indicate that A is still working.
Please advise.
Channels are for communication data. if an channel is non-empty, this means that nobody worked on the content. For signaling that the sender is done, you can close the channel. Like with maps you can also get an bool from a channel.
You might have the XY problem. If you want to signal that some other goroutine did the work, use an atomic bool and check its value.
Обсуждают сегодня