clock

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: MIT Imports: 4 Imported by: 0

README

Disclaimer: WIP.

This is a library for mocking time in Go.

Usage

Example

import "github.com/rkollar/clock"
TODO()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	After(d time.Duration) <-chan time.Time
	Sleep(d time.Duration)
	Tick(d time.Duration) <-chan time.Time
	Since(t time.Time) time.Duration
	NewTicker(d time.Duration) *Ticker
	Now() time.Time
	AfterFunc(d time.Duration, f func()) *Timer
	NewTimer(d time.Duration) *Timer
}

type Mock

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

func NewMock

func NewMock() *Mock

func (*Mock) Advance

func (self *Mock) Advance(d time.Duration)

func (*Mock) After

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

func (*Mock) AfterFunc

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

func (*Mock) NewTicker

func (self *Mock) NewTicker(d time.Duration) *Ticker

func (*Mock) NewTimer

func (self *Mock) NewTimer(d time.Duration) *Timer

func (*Mock) Now

func (self *Mock) Now() time.Time

func (*Mock) Set

func (self *Mock) Set(t time.Time)

func (*Mock) Since

func (self *Mock) Since(t time.Time) time.Duration

func (*Mock) Sleep

func (self *Mock) Sleep(d time.Duration)

func (*Mock) Tick

func (self *Mock) Tick(d time.Duration) <-chan time.Time

type Real

type Real struct{}

func NewReal

func NewReal() *Real

func (*Real) After

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

func (*Real) AfterFunc

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

func (*Real) NewTicker

func (self *Real) NewTicker(d time.Duration) *Ticker

func (*Real) NewTimer

func (self *Real) NewTimer(d time.Duration) *Timer

func (*Real) Now

func (self *Real) Now() time.Time

func (*Real) Since

func (self *Real) Since(t time.Time) time.Duration

func (*Real) Sleep

func (self *Real) Sleep(d time.Duration)

func (*Real) Tick

func (self *Real) Tick(d time.Duration) <-chan time.Time

type Ticker

type Ticker struct {
	C <-chan time.Time
	// contains filtered or unexported fields
}

func (*Ticker) Stop

func (self *Ticker) Stop()

type Timer

type Timer struct {
	C <-chan time.Time
	// contains filtered or unexported fields
}

func (*Timer) Reset

func (self *Timer) Reset(d time.Duration) bool

func (*Timer) Stop

func (self *Timer) Stop() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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