Skip to content

Commit

Permalink
context: add default to select example in comment of Done
Browse files Browse the repository at this point in the history
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
  • Loading branch information
davidhsingyuchen committed Dec 16, 2024
1 parent 3bd08b9 commit 6f2f1e4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ type Context interface {
// select {
// case <-ctx.Done():
// return ctx.Err()
// case out <- v:
// default:
// out <- v
// }
// }
// }
Expand Down

0 comments on commit 6f2f1e4

Please sign in to comment.