mirror of
https://github.com/golang/go.git
synced 2026-04-02 01:10:27 +09:00
context: fix package doc description of WithDeadlineCause and WithTimeoutCause
The package documentation incorrectly states that WithCancelCause, WithDeadlineCause, and WithTimeoutCause all return a CancelCauseFunc. In fact, only WithCancelCause returns a CancelCauseFunc. WithDeadlineCause and WithTimeoutCause accept a cause error parameter directly and return a plain CancelFunc. Update the documentation to accurately describe the difference. Fixes #77478 Change-Id: I581f8a954dd98567bc46e74ded62af927cc48fb2 Reviewed-on: https://go-review.googlesource.com/c/go/+/750824 Reviewed-by: Sean Liao <sean@liao.dev> Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
@@ -24,11 +24,12 @@
|
||||
// child and its children until the parent is canceled. The go vet tool
|
||||
// checks that CancelFuncs are used on all control-flow paths.
|
||||
//
|
||||
// The [WithCancelCause], [WithDeadlineCause], and [WithTimeoutCause] functions
|
||||
// return a [CancelCauseFunc], which takes an error and records it as
|
||||
// the cancellation cause. Calling [Cause] on the canceled context
|
||||
// or any of its children retrieves the cause. If no cause is specified,
|
||||
// Cause(ctx) returns the same value as ctx.Err().
|
||||
// The [WithCancelCause] function returns a [CancelCauseFunc], which takes
|
||||
// an error and records it as the cancellation cause. [WithDeadlineCause]
|
||||
// and [WithTimeoutCause] take a cause to use when the deadline expires.
|
||||
// Calling [Cause] on the canceled context or any of its children retrieves
|
||||
// the cause. If no cause is specified, Cause(ctx) returns the same value
|
||||
// as ctx.Err().
|
||||
//
|
||||
// Programs that use Contexts should follow these rules to keep interfaces
|
||||
// consistent across packages and enable static analysis tools to check context
|
||||
|
||||
Reference in New Issue
Block a user