Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
x/time/rate: allow injecting of time functions to make testing easier #21210
What did you do?
Limiter from x/time/rate directly uses time functions without ability to provide replacement.
When testing code that uses Limiter, it is hard to write a test that doesn't involve the passing of actual wall clock time.
There are also examples of clocks that would be convenient to inject, such as andres-erbsen/clock. Though just a replacement for time.Now() is likely sufficient.
What did you expect to see?
What did you see instead?