Skip to content

Commit 1d3606e

Browse files
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
1 parent 3bd08b9 commit 1d3606e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/context/context.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ type Context interface {
9696
// select {
9797
// case <-ctx.Done():
9898
// return ctx.Err()
99-
// case out <- v:
99+
// default:
100+
// out <- v
100101
// }
101102
// }
102103
// }

0 commit comments

Comments
 (0)