aboutsummaryrefslogtreecommitdiff
path: root/src/context
diff options
context:
space:
mode:
authorMichael Darakananda <pongad@google.com>2017-09-21 10:25:35 +1000
committerIan Lance Taylor <iant@golang.org>2017-09-21 03:00:51 +0000
commiteca45997dfd6cd14a59fbdea2385f6648a0dc786 (patch)
tree8a2c80f36e9b9444549bc3e48b4f2349dd23eca3 /src/context
parent589ea93678850ad1e5c1192df5768177c3104937 (diff)
downloadgo-eca45997dfd6cd14a59fbdea2385f6648a0dc786.tar.gz
go-eca45997dfd6cd14a59fbdea2385f6648a0dc786.zip
context: fix references to "d" in WithDeadline docs
Docs of WithDeadline refers to variable "d" which does not exist in the docs. This commit renames the time argument to "d" to make the doc work. Change-Id: Ifd2c1be7d2e3f7dfb21cd9bb8ff7fc5039c8d3bd Reviewed-on: https://go-review.googlesource.com/65130 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/context')
-rw-r--r--src/context/context.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/context/context.go b/src/context/context.go
index 0fbb572b8e..06580e0465 100644
--- a/src/context/context.go
+++ b/src/context/context.go
@@ -380,25 +380,25 @@ func (c *cancelCtx) cancel(removeFromParent bool, err error) {
//
// Canceling this context releases resources associated with it, so code should
// call cancel as soon as the operations running in this Context complete.
-func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) {
- if cur, ok := parent.Deadline(); ok && cur.Before(deadline) {
+func WithDeadline(parent Context, d time.Time) (Context, CancelFunc) {
+ if cur, ok := parent.Deadline(); ok && cur.Before(d) {
// The current deadline is already sooner than the new one.
return WithCancel(parent)
}
c := &timerCtx{
cancelCtx: newCancelCtx(parent),
- deadline: deadline,
+ deadline: d,
}
propagateCancel(parent, c)
- d := time.Until(deadline)
- if d <= 0 {
+ dur := time.Until(d)
+ if dur <= 0 {
c.cancel(true, DeadlineExceeded) // deadline has already passed
return c, func() { c.cancel(true, Canceled) }
}
c.mu.Lock()
defer c.mu.Unlock()
if c.err == nil {
- c.timer = time.AfterFunc(d, func() {
+ c.timer = time.AfterFunc(dur, func() {
c.cancel(true, DeadlineExceeded)
})
}