clock

package
v0.3.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package clock provides a mockable time abstraction for deterministic testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
}

Clock abstracts time.Now() for testability.

type MockClock

type MockClock struct {
	// contains filtered or unexported fields
}

MockClock returns a fixed or controlled time for testing.

func NewMockClock

func NewMockClock(t time.Time) *MockClock

NewMockClock creates a MockClock starting at the given time.

func (*MockClock) Add

func (m *MockClock) Add(d time.Duration)

Add advances the mock clock by the given duration.

func (*MockClock) Now

func (m *MockClock) Now() time.Time

Now returns the mock clock's current time.

type RealClock

type RealClock struct{}

RealClock uses the real system time.

func (RealClock) Now

func (RealClock) Now() time.Time

Now returns the current time.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL