Clock represents an interface to the functions in the standard library time package. Two implementations are available in the clock package. The first is a real-time clock which simply wraps the time package's functions. The second is a mock clock which will only make forward progress when programmatically adjusted.
New returns an instance of a real-time clock.
Mock represents a mock clock that only moves forward programmically. It can be preferable to a real-time clock when testing time-based functionality.
NewMock returns an instance of a mock clock. The current time of the mock clock on initialization is the Unix epoch.
Add moves the current time of the mock clock forward by the duration. This should only be called from a single goroutine at a time.
After produces a channel that will emit the time after a duration passes.
AfterFunc waits for the duration to elapse and then executes a function. A Timer is returned that can be stopped.
Now returns the current wall time on the mock clock.
Sleep pauses the goroutine for the given duration on the mock clock. The clock must be moved forward in a separate goroutine.
Timer produces a timer that will emit a time some duration after now.
Timer represents a single event.
timers represents a list of sortable timers.