Help us shape the future of Go! Take the 2026 Go Developer Survey

testclock

package
v0.99.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package testclock is a settable clock for tests that would otherwise sleep through a TTL, grace window or rate-limit window.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

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

Clock reports either a frozen instant (New) or the wall clock (Wall), in both cases shifted by every Advance so far. Frozen suits pure in-memory TTL pins; Wall suits integration tests whose other timestamps come from Postgres.

func New

func New() *Clock

New freezes the clock at the current time; only Advance moves it.

func Wall

func Wall() *Clock

Wall follows the wall clock plus the accumulated Advance offset.

func (*Clock) Advance

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

func (*Clock) Now

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

Now is the func() time.Time the seams accept.

Jump to

Keyboard shortcuts

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