Versions in this module Expand all Collapse all v0 v0.2.0 Jul 23, 2025 Changes in this version + var ErrClockIsRunning = errors.New("clock is running") + var ErrClockLocked = errors.New("clock is locked") + var ErrClockNotRunning = errors.New("clock is stopped") + var ErrNotADelorean = errors.New("not a DeLorean clock (cannot go back in time)") + func ContextWithClock(ctx context.Context, c Clock) context.Context + func WaitFor(fn func()) + func Waitable(fn func()) chan struct + type Clock interface + After func(d time.Duration) <-chan time.Time + AfterFunc func(d time.Duration, f func()) *Timer + ContextWithDeadline func(ctx context.Context, d time.Time) (context.Context, context.CancelFunc) + ContextWithDeadlineCause func(ctx context.Context, d time.Time, cause error) (context.Context, context.CancelFunc) + ContextWithTimeout func(ctx context.Context, d time.Duration) (context.Context, context.CancelFunc) + ContextWithTimeoutCause func(ctx context.Context, d time.Duration, cause error) (context.Context, context.CancelFunc) + NewTicker func(d time.Duration) *Ticker + NewTimer func(d time.Duration) *Timer + Now func() time.Time + Since func(t time.Time) time.Duration + Sleep func(d time.Duration) + Tick func(d time.Duration) <-chan time.Time + Until func(t time.Time) time.Duration + var SystemClockInstance Clock = SystemClock{} + func ClockFromContext(ctx context.Context) Clock + type MockClock struct + func NewMockClock(options ...MockClockOption) *MockClock + func (m *MockClock) AdvanceBy(d time.Duration) + func (m *MockClock) AdvanceTo(t time.Time) + func (m *MockClock) After(d time.Duration) <-chan time.Time + func (m *MockClock) AfterFunc(d time.Duration, f func()) *Timer + func (m *MockClock) ContextWithDeadline(ctx context.Context, t time.Time) (context.Context, context.CancelFunc) + func (m *MockClock) ContextWithDeadlineCause(ctx context.Context, t time.Time, cause error) (context.Context, context.CancelFunc) + func (m *MockClock) ContextWithTimeout(ctx context.Context, d time.Duration) (context.Context, context.CancelFunc) + func (m *MockClock) ContextWithTimeoutCause(ctx context.Context, d time.Duration, cause error) (context.Context, context.CancelFunc) + func (m *MockClock) CreatedAt() time.Time + func (m *MockClock) IsRunning() bool + func (m *MockClock) NewTicker(d time.Duration) *Ticker + func (m *MockClock) NewTimer(d time.Duration) *Timer + func (m *MockClock) Now() time.Time + func (m *MockClock) Since(t time.Time) time.Duration + func (m *MockClock) SinceCreated() time.Duration + func (m *MockClock) Sleep(d time.Duration) + func (m *MockClock) Start() + func (m *MockClock) Stop() + func (m *MockClock) Tick(d time.Duration) <-chan time.Time + func (m *MockClock) Until(t time.Time) time.Duration + func (m *MockClock) Update() + type MockClockOption func(*MockClock) + func AtTime(t time.Time) MockClockOption + func DropsTicks() MockClockOption + func InLocation(loc *time.Location) MockClockOption + func StartRunning() MockClockOption + func YieldTime(d time.Duration) MockClockOption + type MockContext struct + func NewMockContext(parent context.Context, clock Clock, deadline time.Time, cause error) (*MockContext, context.CancelFunc) + func (c *MockContext) Deadline() (time.Time, bool) + func (c *MockContext) Done() <-chan struct{} + func (c *MockContext) Err() error + func (c *MockContext) String() string + func (c *MockContext) Value(key any) any + type StartFuncs struct + func (wg *StartFuncs) OnStart(fn func()) + func (wg *StartFuncs) Start() + type SystemClock struct + func (c SystemClock) After(d time.Duration) <-chan time.Time + func (c SystemClock) AfterFunc(d time.Duration, f func()) *Timer + func (c SystemClock) ContextWithDeadline(ctx context.Context, d time.Time) (context.Context, context.CancelFunc) + func (c SystemClock) ContextWithDeadlineCause(ctx context.Context, d time.Time, cause error) (context.Context, context.CancelFunc) + func (c SystemClock) ContextWithTimeout(ctx context.Context, d time.Duration) (context.Context, context.CancelFunc) + func (c SystemClock) ContextWithTimeoutCause(ctx context.Context, d time.Duration, cause error) (context.Context, context.CancelFunc) + func (c SystemClock) NewTicker(d time.Duration) *Ticker + func (c SystemClock) NewTimer(d time.Duration) *Timer + func (c SystemClock) Now() time.Time + func (c SystemClock) Since(t time.Time) time.Duration + func (c SystemClock) Sleep(d time.Duration) + func (c SystemClock) Tick(d time.Duration) <-chan time.Time + func (c SystemClock) Until(t time.Time) time.Duration + type Tickables []tickable + func (a Tickables) Equal(target Tickables) bool + func (a Tickables) Len() int + func (a Tickables) Less(i, j int) bool + func (a Tickables) Swap(i, j int) + type Ticker struct + func (t *Ticker) Reset(d time.Duration) + func (t *Ticker) Stop() + type Timer struct + func (t *Timer) Reset(d time.Duration) bool + func (t *Timer) Stop() bool + type WaitFuncs struct + func (wg *WaitFuncs) Go(fn func())