util

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DurationToString

func DurationToString(minutes int) string

Returns a given duration in minutes formatted as a more human-readable string of hours and minutes.

func Enquote added in v0.9.0

func Enquote(s string) string

Enquote takes a string and surrounds it with quotes, escaping any quotes already present in the given string.

func PadCenter added in v0.7.5

func PadCenter(s string, length int) string

func TruncateAt

func TruncateAt(s string, length int) string

TODO: test and use in appropriate places

Types

type MetricsGetter

type MetricsGetter interface {
	Avg() uint64
	GetLast() uint64
}

MetricsGetter allows access to tracked performance metrics.

type MetricsHandler

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

MetricsHandler takes care of storing and updating tracked performance metrics and computes a rolling average to give basic insight into program performance.

func (*MetricsHandler) Add

func (h *MetricsHandler) Add(value uint64)

Add inserts a new performance value into the ring buffer.

func (*MetricsHandler) Avg

func (h *MetricsHandler) Avg() uint64

Avg returns the average from the ring buffer. Note that this can be misleading before the ring buffer has been filled up.

func (*MetricsHandler) GetLast

func (h *MetricsHandler) GetLast() uint64

GetLast returns the most recently added performance value.

type Rect

type Rect struct {
	X, Y, W, H int
}

func NewRect

func NewRect(x, y, w, h int) *Rect

NewRect constructs and returns a Rect.

func (Rect) Contains

func (r Rect) Contains(x, y int) bool

Jump to

Keyboard shortcuts

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