xtime

package
v0.0.0-...-7d52cfa Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 1 Imported by: 0

README

xtime

Lightweight mock for time package.

A dedicated package such as jonboulle/clockwork would be better, but I would rather limit dependencies for this package. clockwork does not support Go 1.18 anymore.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Now

func Now() time.Time

func SetClock

func SetClock(c Clock)

func Since

func Since(t time.Time) time.Duration

func Sleep

func Sleep(d time.Duration)

func Until

func Until(t time.Time) time.Duration

Types

type Clock

type Clock interface {
	Now() time.Time
	Since(t time.Time) time.Duration
	Until(t time.Time) time.Duration
	Sleep(d time.Duration)
}

type FakeClock

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

func NewFakeClock

func NewFakeClock() *FakeClock

func NewFakeClockAt

func NewFakeClockAt(t time.Time) *FakeClock

func (*FakeClock) Now

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

func (*FakeClock) Since

func (c *FakeClock) Since(t time.Time) time.Duration

func (*FakeClock) Sleep

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

func (*FakeClock) Until

func (c *FakeClock) Until(t time.Time) time.Duration

type RealClock

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

func NewRealClock

func NewRealClock() *RealClock

func (*RealClock) Now

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

func (*RealClock) Since

func (c *RealClock) Since(t time.Time) time.Duration

func (*RealClock) Sleep

func (c *RealClock) Sleep(d time.Duration)

func (*RealClock) Until

func (c *RealClock) Until(t time.Time) time.Duration

Jump to

Keyboard shortcuts

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