uber-go/ratelimit ? reverse-engineered prompt
Reverse engineered prompt
Build me a small Go library that does blocking rate limiting with a simple API.
I want to be able to create a limiter with a max number of operations per second, then call Take before each operation and have it sleep until it is okay to continue. It should use a leaky bucket style approach, where the timing is based on elapsed time between requests, not on a fixed refill tick.
Please make it easy to use in normal Go code, with a tiny public surface area and good tests showing the timing behavior. Include an example that prints the delay between calls, and make sure the limiter is accurate enough for common use, while keeping overhead low. If there are a couple of reasonable implementation approaches, pick the simplest one that performs well and feels clean. Look up current Go docs online if you need to.
Are you gonna build this?
make sure you review the code using coderabbit