We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go version
$ go version go version go1.17.8 darwin/arm64
Yes
go env
$ go env GO111MODULE="on" GOARCH="arm64" GOBIN="" GOCACHE="/Users/jiabiao/Library/Caches/go-build" GOENV="/Users/jiabiao/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="arm64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/jiabiao/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/jiabiao/go" GOPRIVATE="" GOPROXY="" GOROOT="/usr/local/go" GOSUMDB="" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64" GOVCS="" GOVERSION="go1.17.8" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/dev/null" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/r0/1xtsxl1j5kb0yn0_9zn00kh80000gn/T/go-build2026362806=/tmp/go-build -gno-record-gcc-switches -fno-common"
run https://go.dev/play/p/Zf2hlyhvZY0
func main() { l := rate.NewLimiter(1, 1) now := time.Now() fmt.Println(l.AllowN(now, 1)) fmt.Println(l.AllowN(now.Add(time.Second), 1)) fmt.Println(l.AllowN(now, 1)) fmt.Println(l.AllowN(now.Add(time.Second), 1)) }
true true false false
true true false true
The text was updated successfully, but these errors were encountered:
program execution takes time, which affects the point of evaluation. Note from the documentation:
in any large enough time interval, the Limiter limits the rate to r tokens per second
Changing the order of the lines will give you different results.
Sorry, something went wrong.
No branches or pull requests
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
run https://go.dev/play/p/Zf2hlyhvZY0
func main() {
l := rate.NewLimiter(1, 1)
now := time.Now()
fmt.Println(l.AllowN(now, 1))
fmt.Println(l.AllowN(now.Add(time.Second), 1))
fmt.Println(l.AllowN(now, 1))
fmt.Println(l.AllowN(now.Add(time.Second), 1))
}
What did you expect to see?
true
true
false
false
What did you see instead?
true
true
false
true
The text was updated successfully, but these errors were encountered: