[time] rate: use time.Since instead of time.Now().Sub

270 views
Skip to first unread message

Tobias Klauser (Gerrit)

unread,
Jun 7, 2021, 6:45:09 AM6/7/21
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Tobias Klauser has uploaded this change for review.

View Change

rate: use time.Since instead of time.Now().Sub

Change-Id: I140abf9d9283edb7259c9aa13ee69f3ca33181e6
---
M rate/rate_test.go
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rate/rate_test.go b/rate/rate_test.go
index 866347c..2491be7 100644
--- a/rate/rate_test.go
+++ b/rate/rate_test.go
@@ -401,7 +401,7 @@
func runWait(t *testing.T, lim *Limiter, w wait) {
start := time.Now()
err := lim.WaitN(w.ctx, w.n)
- delay := time.Now().Sub(start)
+ delay := time.Since(start)
if (w.nilErr && err != nil) || (!w.nilErr && err == nil) || w.delay != dFromDuration(delay) {
errString := "<nil>"
if !w.nilErr {

To view, visit change 325609. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: time
Gerrit-Branch: master
Gerrit-Change-Id: I140abf9d9283edb7259c9aa13ee69f3ca33181e6
Gerrit-Change-Number: 325609
Gerrit-PatchSet: 1
Gerrit-Owner: Tobias Klauser <tobias....@gmail.com>
Gerrit-Reviewer: Tobias Klauser <tobias....@gmail.com>
Gerrit-MessageType: newchange

Ian Lance Taylor (Gerrit)

unread,
Jun 7, 2021, 6:10:26 PM6/7/21
to Tobias Klauser, goph...@pubsubhelper.golang.org, Go Bot, golang-co...@googlegroups.com

Attention is currently required from: Tobias Klauser.

Patch set 1:Code-Review +2

View Change

    To view, visit change 325609. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: time
    Gerrit-Branch: master
    Gerrit-Change-Id: I140abf9d9283edb7259c9aa13ee69f3ca33181e6
    Gerrit-Change-Number: 325609
    Gerrit-PatchSet: 1
    Gerrit-Owner: Tobias Klauser <tobias....@gmail.com>
    Gerrit-Reviewer: Go Bot <go...@golang.org>
    Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Reviewer: Tobias Klauser <tobias....@gmail.com>
    Gerrit-Attention: Tobias Klauser <tobias....@gmail.com>
    Gerrit-Comment-Date: Mon, 07 Jun 2021 22:10:21 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Tobias Klauser (Gerrit)

    unread,
    Jun 8, 2021, 1:32:58 AM6/8/21
    to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Ian Lance Taylor, Go Bot, golang-co...@googlegroups.com

    Tobias Klauser submitted this change.

    View Change

    Approvals: Ian Lance Taylor: Looks good to me, approved Tobias Klauser: Trusted; Run TryBots Go Bot: TryBots succeeded
    rate: use time.Since instead of time.Now().Sub

    Change-Id: I140abf9d9283edb7259c9aa13ee69f3ca33181e6
    Reviewed-on: https://go-review.googlesource.com/c/time/+/325609
    Trust: Tobias Klauser <tobias....@gmail.com>
    Run-TryBot: Tobias Klauser <tobias....@gmail.com>
    TryBot-Result: Go Bot <go...@golang.org>
    Reviewed-by: Ian Lance Taylor <ia...@golang.org>

    ---
    M rate/rate_test.go
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/rate/rate_test.go b/rate/rate_test.go
    index 866347c..2491be7 100644
    --- a/rate/rate_test.go
    +++ b/rate/rate_test.go
    @@ -401,7 +401,7 @@
    func runWait(t *testing.T, lim *Limiter, w wait) {
    start := time.Now()
    err := lim.WaitN(w.ctx, w.n)
    - delay := time.Now().Sub(start)
    + delay := time.Since(start)
    if (w.nilErr && err != nil) || (!w.nilErr && err == nil) || w.delay != dFromDuration(delay) {
    errString := "<nil>"
    if !w.nilErr {

    To view, visit change 325609. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: time
    Gerrit-Branch: master
    Gerrit-Change-Id: I140abf9d9283edb7259c9aa13ee69f3ca33181e6
    Gerrit-Change-Number: 325609
    Gerrit-PatchSet: 2
    Gerrit-Owner: Tobias Klauser <tobias....@gmail.com>
    Gerrit-Reviewer: Go Bot <go...@golang.org>
    Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Reviewer: Tobias Klauser <tobias....@gmail.com>
    Gerrit-MessageType: merged
    Reply all
    Reply to author
    Forward
    0 new messages