format

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KiB = 1024
	MiB = 1048576
	GiB = 1073741824
	TiB = 1099511627776

	KB = 1e3
	MB = 1e6
	GB = 1e9
	TB = 1e12
)

Variables

View Source
var DefaultFormat = ProgressFormat{
	BoxStart:  "[",
	BoxEnd:    "]",
	Empty:     " ",
	Current:   ">",
	Completed: "=",
	Spin:      []rune{'\\', '|', '/', '-'},
}

Functions

func EscapeAwareRuneCountInString

func EscapeAwareRuneCountInString(s string) int

func Format

func Format(i int64) *formatter

Types

type ProgressFormat

type ProgressFormat struct {
	BoxStart  string
	BoxEnd    string
	Empty     string
	Current   string
	Completed string
	Spin      []rune
}

func (*ProgressFormat) String

func (pf *ProgressFormat) String() string

type Units

type Units int
const (
	// U_NO are default units, they represent a simple value and are not formatted at all.
	U_NO Units = iota
	// U_BYTES units are formatted in a human readable way (B, KiB, MiB, ...)
	U_BYTES
	// U_BYTES_DEC units are like U_BYTES, but base 10 (B, KB, MB, ...)
	U_BYTES_DEC
	// U_DURATION units are formatted in a human readable way (3h14m15s)
	U_DURATION
)

Jump to

Keyboard shortcuts

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