File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change @@ -42,8 +42,6 @@ func (l *Limiter) WaitN(ctx context.Context, n int) error {
4242 return fmt .Errorf ("rate: Wait (n=%d) exceed limiter %d" , n , l .limit )
4343 }
4444
45- now := time .Now ()
46-
4745 // Get the oldest request in queue for waiting.
4846 var (
4947 shouldWait bool
@@ -56,7 +54,7 @@ func (l *Limiter) WaitN(ctx context.Context, n int) error {
5654
5755 // Wait if rate limit is reached.
5856 if shouldWait {
59- waitDuration := l .period - now . Sub (oldest )
57+ waitDuration := l .period - time . Since (oldest )
6058 if waitDuration > 0 {
6159 timer := time .NewTimer (waitDuration )
6260 defer timer .Stop ()
@@ -73,7 +71,7 @@ func (l *Limiter) WaitN(ctx context.Context, n int) error {
7371
7472 // Add new requests to queue.
7573 for range n {
76- l .addRequest (now )
74+ l .addRequest (time . Now () )
7775 }
7876
7977 return nil
You can’t perform that action at this time.
0 commit comments