util

package
v0.0.4-0...-7259d3a Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: GPL-3.0 Imports: 6 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BlockChar = `█`
View Source
var HBarChar = []string{
	` `,
	`▏`,
	`▎`,
	`▍`,
	`▌`,
	`▋`,
	`▊`,
	`▉`,
	`█`,
}
View Source
var VBarChar = []string{
	` `,
	`_`,
	`▁`,
	`▂`,
	`▃`,
	`▄`,
	`▅`,
	`▆`,
}

Functions

func FormatDuration

func FormatDuration(t time.Duration) string

Formats duration. Does not go over 7 characters till 9999+h

func FormatDurationPadded

func FormatDurationPadded(t time.Duration) string

FormatDuration with added padding to 7 (

func FormatUnitBytes

func FormatUnitBytes(bytes int64) (s string)

format bytes

func GenerateColorBarLookupTable

func GenerateColorBarLookupTable() (colorTable map[int8]string, barTable map[int8]string)

func GetBarChar

func GetBarChar(pct int) string

generate bar chart from percent

func GetColorPct

func GetColorPct(pct int) string

generate color from percentage (0 - good/green 100 - bad/red)

func GetUnitBytes

func GetUnitBytes(bytes int64) (divider int, unit string)

calculate divider and unit for bytes

func IntOrZero

func IntOrZero(s string) int

return int, 0 if nonparsable

func Sub100

func Sub100(i int) int

func WaitForTs

func WaitForTs(nextTs *time.Time)

Types

type Template

type Template struct {
	*template.Template
	// contains filtered or unexported fields
}

func NewTemplate

func NewTemplate(name string, tpl string) (*Template, error)

func (Template) ExecuteString

func (t Template) ExecuteString(i interface{}) string

Jump to

Keyboard shortcuts

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