I also started using benbjohnson/clock about a year ago, but discovered that it wasn't a perfect fit:

- Even though Clock is an interface, Timer is not. This means that if you want to use that package in combination with gomock, you're out of luck.

- The Clock interface doesn't provide a wrapper for context.WithTimeout(), which also depends on the system clock.

- Nit: The Clock interface also exposes functions like time.After(), which should in my opinion never be used in production code, as they don't support efficient cancelation. You should use timers instead.

In the end I resorted to writing my own set of interfaces.

Code: https://github.com/buildbarn/bb-storage/tree/master/pkg/cloc...

Documentation: https://pkg.go.dev/github.com/buildbarn/bb-storage/pkg/clock

Not a mock obviously but in the interest of getting things done on schedule I’d suggest running tests in a container with https://github.com/wolfcw/libfaketime and orchestrating edge cases like leap seconds external to the test suite itself.