diff options
Diffstat (limited to 'vendor/golang.org/x/time')
-rw-r--r-- | vendor/golang.org/x/time/README | 1 | ||||
-rw-r--r-- | vendor/golang.org/x/time/README.md | 17 | ||||
-rw-r--r-- | vendor/golang.org/x/time/rate/rate.go | 11 |
3 files changed, 24 insertions, 5 deletions
diff --git a/vendor/golang.org/x/time/README b/vendor/golang.org/x/time/README deleted file mode 100644 index 144e347b4..000000000 --- a/vendor/golang.org/x/time/README +++ /dev/null @@ -1 +0,0 @@ -This repository provides supplementary Go time packages. diff --git a/vendor/golang.org/x/time/README.md b/vendor/golang.org/x/time/README.md new file mode 100644 index 000000000..ce9becdde --- /dev/null +++ b/vendor/golang.org/x/time/README.md @@ -0,0 +1,17 @@ +# Go Time + +This repository provides supplementary Go time packages. + +## Download/Install + +The easiest way to install is to run `go get -u golang.org/x/time`. You can +also manually git clone the repository to `$GOPATH/src/golang.org/x/time`. + +## Report Issues / Send Patches + +This repository uses Gerrit for code changes. To learn how to submit changes to +this repository, see https://golang.org/doc/contribute.html. + +The main issue tracker for the time repository is located at +https://github.com/golang/go/issues. Prefix your issue with "x/time:" in the +subject line, so it is easy to find. diff --git a/vendor/golang.org/x/time/rate/rate.go b/vendor/golang.org/x/time/rate/rate.go index 938feaffe..ae93e2471 100644 --- a/vendor/golang.org/x/time/rate/rate.go +++ b/vendor/golang.org/x/time/rate/rate.go @@ -6,12 +6,11 @@ package rate import ( + "context" "fmt" "math" "sync" "time" - - "golang.org/x/net/context" ) // Limit defines the maximum frequency of some events. @@ -244,8 +243,12 @@ func (lim *Limiter) WaitN(ctx context.Context, n int) (err error) { if !r.ok { return fmt.Errorf("rate: Wait(n=%d) would exceed context deadline", n) } - // Wait - t := time.NewTimer(r.DelayFrom(now)) + // Wait if necessary + delay := r.DelayFrom(now) + if delay == 0 { + return nil + } + t := time.NewTimer(delay) defer t.Stop() select { case <-t.C: |