diff options
author | Brad Fitzpatrick <bradfitz@golang.org> | 2016-08-30 01:05:18 +0000 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-08-30 01:23:46 +0000 |
commit | 298791a94af8b787c38fb95c51cb2dbc94668dad (patch) | |
tree | bbd6720558afa7d8455bd3085765d12d68ff23fb /src/context | |
parent | 6c6ad08eb920d02947410919889229bbfa8c9915 (diff) | |
download | go-298791a94af8b787c38fb95c51cb2dbc94668dad.tar.gz go-298791a94af8b787c38fb95c51cb2dbc94668dad.zip |
all: use time.Until where applicable
Updates #14595
Change-Id: Idf60b3004c7a0ebb59dd48389ab62c854069e09f
Reviewed-on: https://go-review.googlesource.com/28073
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/context')
-rw-r--r-- | src/context/context.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/context/context.go b/src/context/context.go index f8ce9ccdb8..e40b63ef3c 100644 --- a/src/context/context.go +++ b/src/context/context.go @@ -376,7 +376,7 @@ func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { deadline: deadline, } propagateCancel(parent, c) - d := deadline.Sub(time.Now()) + d := time.Until(deadline) if d <= 0 { c.cancel(true, DeadlineExceeded) // deadline has already passed return c, func() { c.cancel(true, Canceled) } @@ -406,7 +406,7 @@ func (c *timerCtx) Deadline() (deadline time.Time, ok bool) { } func (c *timerCtx) String() string { - return fmt.Sprintf("%v.WithDeadline(%s [%s])", c.cancelCtx.Context, c.deadline, c.deadline.Sub(time.Now())) + return fmt.Sprintf("%v.WithDeadline(%s [%s])", c.cancelCtx.Context, c.deadline, time.Until(c.deadline)) } func (c *timerCtx) cancel(removeFromParent bool, err error) { |