timeutil

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SecondsAsDuration

func SecondsAsDuration(seconds float64) time.Duration

SecondsAsDuration is a simple shortcut for converting seconds represented as a float to a `time.Duration`.

Types

type TickerWithInitialTick

type TickerWithInitialTick struct {
	// C fires once on initial startup, then after each interval has passed.
	C <-chan time.Time
	// contains filtered or unexported fields
}

TickerWithInitialTick is similar to `time.Ticker`, except that it fires once immediately upon initialization. It also respects context cancellation and prefers to be stopped that way rather than an explicit `Stop` function.

func NewTickerWithInitialTick

func NewTickerWithInitialTick(ctx context.Context, interval time.Duration) *TickerWithInitialTick

NewTickerWithInitialTick creates a new ticker similar to `time.Ticker`, except that it fires once immediately upon initialization. It also respects context cancellation and prefers to be stopped that way rather than an explicit `Stop` function.

Jump to

Keyboard shortcuts

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