Why Go Limiter isn't working when limit = 0?

Viewed 206

I'm using Go Limiter and seems not working properly when Limit is 0. It's supposed to reject all events, but it doesn't. (Note that I'm not using rate.Every(), with set limit Inf in case of 0)

The code:

package main

import (
    "fmt"
    "golang.org/x/time/rate"
)

func main() {
    rl := rate.NewLimiter(0, 1)

    for i := 0; i < 1000; i++ {
        fmt.Println(rl.Allow())
    }

}

The results is all true.

You can check on this playground

1 Answers
Related