boulder/vendor/github.com/jmhodges/clock
dependabot[bot] 9800065061
build(deps): Bump github.com/jmhodges/clock from 0.0.0-20160418191101-880ee4c33548 to 1.2.0 (#6766)
Bumps https://github.com/jmhodges/clock from
0.0.0-20160418191101-880ee4c33548 to 1.2.0.

This update contains no code changes, but does get us off
of a pseudoversion.
2023-03-28 15:17:28 -07:00
..
.travis.yml Switch to new vendor style (#1747) 2016-04-18 12:51:36 -07:00
LICENSE Switch to new vendor style (#1747) 2016-04-18 12:51:36 -07:00
README.md build(deps): Bump github.com/jmhodges/clock from 0.0.0-20160418191101-880ee4c33548 to 1.2.0 (#6766) 2023-03-28 15:17:28 -07:00
clock.go build(deps): Bump github.com/jmhodges/clock from 0.0.0-20160418191101-880ee4c33548 to 1.2.0 (#6766) 2023-03-28 15:17:28 -07:00
timer.go Add gRPC client side metrics (#2151) 2016-09-09 15:17:36 -04:00

README.md

clock

GoDoc

Package clock provides an abstraction for system time that enables testing of time-sensitive code.

Where you'd use time.Now, instead use clk.Now where clk is an instance of clock.Clock.

When running your code in production, pass it a Clock given by clock.Default() and when you're running it in your tests, pass it an instance of Clock from NewFake().

When you do that, you can use FakeClock's Add and Set methods to control how time behaves in your tests. That makes the tests you'll write more reliable while also expanding the space of problems you can test.

This code intentionally does not attempt to provide an abstraction over time.Ticker and time.Timer because Go does not have the runtime or API hooks available to do so reliably. See https://github.com/golang/go/issues/8869

As with any use of time, be sure to test Time equality with time.Time#Equal, not ==.

For API documentation, see the godoc.