ctime

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTicker added in v1.6.0

func NewTicker(ctx context.Context, interval time.Duration) <-chan struct{}

NewTicker returns a channel that emits ticks starting immediately and then roughly every `interval` thereafter.

Design goals:

  • Single goroutine, single time.Timer (no busy waits, no extra deps).
  • Coalescing semantics: if the consumer is slow, ticks do NOT accumulate. The channel is buffered with size 1; sending is non-blocking.
  • Monotonic scheduling: next tick time is advanced by fixed `interval` from the *ideal* schedule (next += interval), preserving cadence and avoiding bursts if we ever fall behind.
  • Cancellation via ctx.Done().
  • If interval <= 0, falls back to 1s.

First tick is sent immediately (best for “kick off then repeat” workflows).

func Now

func Now() time.Time

func Since

func Since(t time.Time) time.Duration

func Start

func Start(resolution time.Duration) func()

func UnixNano

func UnixNano() int64

Types

This section is empty.

Jump to

Keyboard shortcuts

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