sethvargo/go-limiter ? reverse-engineered prompt
Reverse engineered prompt
Build me a small Go rate limiting library that can be used in normal apps and HTTP servers.
I want a simple store based API where I can set a token limit and reset interval, then call something like Take with a string key and get back whether the request is allowed, how many tokens are left, and when it resets. Please include an in memory implementation for fast local use, and a no op implementation for testing or when I want to disable limiting.
Also add HTTP middleware for Go’s standard library so I can wrap a handler and rate limit by client IP or another custom key function. It should automatically set the usual rate limit headers, including the limit, remaining count, reset time, and Retry After when a request is blocked.
Keep it dependency free if possible, use only the Go standard library, and make sure the code is clean, well tested, and easy to use from a small example in the README. If you need to check current library docs or best practices online, go ahead and look them up.
Are you gonna build this?
make sure you review the code using coderabbit