clock

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

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
}

Clock provides an abstraction for time operations to enable deterministic testing.

type FakeClock

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

FakeClock implements Clock with a fixed time for testing.

func NewFakeClock

func NewFakeClock(t time.Time) *FakeClock

NewFakeClock creates a new FakeClock with the given time.

func (*FakeClock) Advance

func (c *FakeClock) Advance(d time.Duration)

Advance moves the fixed time forward by the given duration.

func (*FakeClock) Now

func (c *FakeClock) Now() time.Time

Now returns the fixed time.

func (*FakeClock) Set

func (c *FakeClock) Set(t time.Time)

Set updates the fixed time.

type RealClock

type RealClock struct{}

RealClock implements Clock using the system time.

func (*RealClock) Now

func (c *RealClock) Now() time.Time

Now returns the current system time.

Jump to

Keyboard shortcuts

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