clock

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package clock provides an interface around the standard library's time package so that unit tests can inject a mock clock.

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 represents a source of the current time.

func Mock added in v0.2.0

func Mock(logger *slog.Logger) Clock

Mock returns a Clock that reads the MOCK_TIME env variable if set to an RFC3339 timestamp, otherwise it uses time.Now.

type Func

type Func func() time.Time

Func is an adapter that allows a function returning time.Time (such as time.Now) to satisfy the Clock interface.

func (Func) Now

func (f Func) Now() time.Time

Now returns the time produced by the underlying function.

Jump to

Keyboard shortcuts

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