type MockClock … // NewMockClock builds a new mock clock // using the current actual time as the initial time. func NewMockClock() *MockClock { … } // Now reports the current time. func (c *MockClock) Now() time.Time { … } // NewTicker returns a time.Ticker that ticks at the specified frequency. // // As with [time.NewTicker], // the ticker will drop ticks if the receiver is slow, // and the channel is never closed. // // Calling Stop on the returned ticker is a no-op. // The ticker only runs when the clock is advanced. func (c *MockClock) NewTicker(d time.Duration) *time.Ticker { … } // runAt schedules the given function to be run at the given time. // The function runs without a lock held, so it may schedule more work. func (c *MockClock) runAt(t time.Time, fn func()) { … } type waiter … // Add progresses time by the given duration. // Other operations waiting for the time to advance // will be resolved if they are within range. // // Side effects of operations waiting for the time to advance // will take effect on a best-effort basis. // Avoid racing with operations that have side effects. // // Panics if the duration is negative. func (c *MockClock) Add(d time.Duration) { … }