Limit the rate of operations per time unit, use a time.Ticker. This implementation refills the bucket based on the time elapsed between requests.
Create new bucket Refills every 18 seconds with 3 new requests and the bucket limit is 25
go get github.com/numero33/ratelimit
lr, err := ratelimit.NewLimiter(WithDuration(18*time.Second), WithAmount(3), WithLimit(25))
if err != nil {
log.Fatal("ratelimit.NewLimiter")
}
to get a request
log.print("Wait for Slot")
lr.Take()