utils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisplayASCII

func DisplayASCII(b []byte) string

DisplayASCII represents a key as ascii if it only contains safe ascii characters. If it contains unsafe characters, these are replaced by '.' and a hex representation is added to the output. It the first 8 bytes look like a nanosecond UNIX timestamp, that will be shown too. TODO: Support full LS header

func GC

func GC() time.Duration

GC runs the garbage collector and logs some memory stats

func IsCanceled

func IsCanceled(ctx context.Context) bool

IsCanceled checks if the context has been canceled.

func SleepContext

func SleepContext(ctx context.Context, d time.Duration) error

SleepContext sleeps for given duration. If the context closes in the meantime, it returns immediately with a context.Canceled error.

func SleepContextPerturb

func SleepContextPerturb(ctx context.Context, d time.Duration) error

SleepContextPerturb sleeps for given duration like SleepContent, but it perturbs the duration with a 20% random component to avoid multiple instances running at the exact same time. If the context closes in the meantime, it returns immediately with a context.Canceled error.

func TimeDiff

func TimeDiff(t1, t0 time.Time) time.Duration

TimeDiff returns the difference between two times, rounded to milliseconds.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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