Documentation
¶
Overview ¶
Package times provides a clock interface with implementations for production and testing code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock interface {
// Now returns the current time.
Now() time.Time
// After returns a channel that can be used to receive the current time once, after the specified
// duration has passed.
After(time.Duration) <-chan time.Time
}
Clock defines an interface with primitives for time related functionality.
type TestClock ¶
type TestClock struct {
// contains filtered or unexported fields
}
TestClock is a test implementation of the Clock interface. On top of the Clock methods, it adds the possibility to manually step time or to virtually jump to a specified time.
func Test ¶
func Test() TestClock
Test creates a Clock implementation with manual time stepping function. Meant to be used with testing code.
func TestFrom ¶
TestFrom creates a Clock implementation with manual time stepping function, starting from the specified time. Meant to be used with testing code.
func (TestClock) After ¶
After returns a channel that communicates the current time if the specified duration has passed.
func (TestClock) Jump ¶
Jump sets the clock to time specified by t. Values of t in the past, relative to TestClock's current time, are ignored.