aboutsummaryrefslogtreecommitdiff
path: root/src/context/example_test.go
diff options
context:
space:
mode:
authorDamien Neil <dneil@google.com>2025-01-03 11:47:39 -0800
committerGopher Robot <gobot@golang.org>2025-01-03 14:30:13 -0800
commitf966695ccea356e4e4e8cc0328276e2d00c9fc1e (patch)
tree29297273c95f764be5fe37155ad35af2390949a0 /src/context/example_test.go
parent5da026354c0229c5a61dbe907c080cef7adc11bc (diff)
downloadgo-f966695ccea356e4e4e8cc0328276e2d00c9fc1e.tar.xz
context: use "canceled" in docs to refer to timed-out contexts
In documentation, we've usually but not always referred to a context with a closed Done channel as "done" rather than "canceled", to avoid ambiguity between a context canceled by calling a CancelFunc and one past its deadline. This actually adds ambiguity, however, since it's common to see references to a "canceled context" that are intended to cover contexts past their deadline. If you see "function F returns if its context is canceled", you can reasonably assume that F will return if its context passes its deadline, unless something says otherwise. Update the context package docs to explicitly state that a context is canceled when its deadline passes. Drop references to contexts becoming "done" and just use "canceled" throughout. Fixes #70945 Change-Id: I99fbd800c6049deaa37015a304f7f9d9a84100e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/640095 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/context/example_test.go')
-rw-r--r--src/context/example_test.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/context/example_test.go b/src/context/example_test.go
index b597b09f16..be8cd8376e 100644
--- a/src/context/example_test.go
+++ b/src/context/example_test.go
@@ -146,8 +146,8 @@ func ExampleAfterFunc_cond() {
defer stopf()
// Since the wakeups are using Broadcast instead of Signal, this call to
- // Wait may unblock due to some other goroutine's context becoming done,
- // so to be sure that ctx is actually done we need to check it in a loop.
+ // Wait may unblock due to some other goroutine's context being canceled,
+ // so to be sure that ctx is actually canceled we need to check it in a loop.
for !conditionMet() {
cond.Wait()
if ctx.Err() != nil {