By the current official implementation, communicate will never happen.
Because the send and receive goroutines are never put into the wait queues.
On Thursday, March 12, 2026 at 9:50:19 PM UTC Inchs Nicodi wrote:
> Two goroutines are using the same unbuffered channel.
>
> One sends on it inside a select with a default clause.
> The other receives from it inside a select with a default clause.
>
> goroutine 1:
> for {
> select {
> case obj <- ch:
> default:
> }
> ....
> }
>
> goroutine 2:
> for {
> select {
> case ch <- obj:
> default:
> }
> ....
> }
>
> The channel is unbuffered.
>
> Can these two goroutines ever communicate with each other?
> It's a difficult thing to test if they never meet except once in a billion
> attempts.
>
> I've looked at runtime/chan.go but I'm not sure if this depends on what
> the compiler generates for those select statements.
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/golang-nuts/125620e7-5409-40bb-9c6c-9c1b9c7e14dbn%40googlegroups.com.