ttime

package
v1.15.5 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 1 Imported by: 30

Documentation

Overview

Package ttime implements a testable alternative to the Go "time" package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultTime

type DefaultTime struct{}

DefaultTime is a Time that behaves normally

func (*DefaultTime) After

func (*DefaultTime) After(d time.Duration) <-chan time.Time

After sleeps for the given duration and then writes to to the returned channel

func (*DefaultTime) AfterFunc

func (*DefaultTime) AfterFunc(d time.Duration, f func()) Timer

AfterFunc waits for the duration to elapse and then calls f in its own goroutine. It returns a Timer that can be used to cancel the call using its Stop method.

func (*DefaultTime) Now

func (*DefaultTime) Now() time.Time

Now returns the current time

func (*DefaultTime) Sleep

func (*DefaultTime) Sleep(d time.Duration)

Sleep sleeps for the given duration

type Time

type Time interface {
	Now() time.Time
	Sleep(d time.Duration)
	After(d time.Duration) <-chan time.Time
	AfterFunc(d time.Duration, f func()) Timer
}

Time represents an implementation for this package's methods

type Timer

type Timer interface {
	Reset(d time.Duration) bool
	Stop() bool
}

Timer is the timer interface

Directories

Path Synopsis
Package mock_ttime is a generated GoMock package.
Package mock_ttime is a generated GoMock package.

Jump to

Keyboard shortcuts

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