From 6f2f1e4551f14b61c0710bc7884131f0aa0d09fc Mon Sep 17 00:00:00 2001 From: "Hsing-Yu (David) Chen" Date: Mon, 16 Dec 2024 13:08:48 -0500 Subject: [PATCH] context: add default to select example in comment of Done According to the comment of Stream, it should return once ctx.Done is closed, but the current implementation may select another case instead if out is ready to receive an element. Quoting from the related Go spec: "If one or more of the communications can proceed, a single one that can proceed is chosen via a uniform pseudo-random selection." https://go.dev/ref/spec#Select_statements --- src/context/context.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/context/context.go b/src/context/context.go index db8bc69553ebe8..b3b890f6f18353 100644 --- a/src/context/context.go +++ b/src/context/context.go @@ -96,7 +96,8 @@ type Context interface { // select { // case <-ctx.Done(): // return ctx.Err() - // case out <- v: + // default: + // out <- v // } // } // }