clock

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Default is a proxy to the [time] package.
	Default = defaultClock{}
)

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
}

Clock defines methods of a clock.

type Fake

type Fake struct {
	Base time.Time
	// contains filtered or unexported fields
}

Fake fakes the clock. Useful in tests.

func NewFakeDefault

func NewFakeDefault() *Fake

NewFakeDefault returns Fake initialized at 2000-01-01T00:00:00Z.

func (*Fake) Add added in v0.44.0

func (fc *Fake) Add(d time.Duration)

Add advances the fake clock by d. It is safe to call this method from multiple goroutines.

func (*Fake) Now

func (fc *Fake) Now() time.Time

Now fakes the current time. It returns whatever base value to clock currently contains. It increases the base value by one second for each call to make it possible to check a sequence of calls.

Jump to

Keyboard shortcuts

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