util

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CLEAR = "\033[0m"

	// Forground color
	BLACK  = "\033[30"
	RED    = "\033[31"
	GREEN  = "\033[32"
	YELLOW = "\033[33"
	BLUE   = "\033[34"
	PURPLE = "\033[35"
	CYAN   = "\033[36"
	WHITE  = "\033[37"

	BRIGHT    = ";1m"
	DIM       = ";2m"
	UNDERLINE = ";4m"
	//FLASH = ";5m"
	REVERSE = ";7m"

	WHITE_TEXT_SOFT_BG = "\x1b[48;5;235m\x1b[37m"
	RED_TEXT_GREEN_BG  = "\033[31m\033[42m"
	WHITE_TEXT_RED_BG  = "\033[37m\033[41m"

	BRIGHT_BLACK    = BLACK + BRIGHT
	DIM_BLACK       = BLACK + DIM
	UNDERLINE_BLACK = BLACK + UNDERLINE
	REVERSE_BLACK   = BLACK + REVERSE

	BRIGHT_RED    = RED + BRIGHT
	DIM_RED       = RED + DIM
	UNDERLINE_RED = RED + UNDERLINE
	REVERSE_RED   = RED + REVERSE

	BRIGHT_GREEN    = GREEN + BRIGHT
	DIM_GREEN       = GREEN + DIM
	UNDERLINE_GREEN = GREEN + UNDERLINE
	REVERSE_GREEN   = GREEN + REVERSE

	BRIGHT_YELLOW    = YELLOW + BRIGHT
	DIM_YELLOW       = YELLOW + DIM
	UNDERLINE_YELLOW = YELLOW + UNDERLINE
	REVERSE_YELLOW   = YELLOW + REVERSE

	BRIGHT_BLUE    = BLUE + BRIGHT
	DIM_BLUE       = BLUE + DIM
	UNDERLINE_BLUE = BLUE + UNDERLINE
	REVERSE_BLUE   = BLUE + REVERSE

	BRIGHT_PURPLE    = PURPLE + BRIGHT
	DIM_PURPLE       = PURPLE + DIM
	UNDERLINE_PURPLE = PURPLE + UNDERLINE
	REVERSE_PURPLE   = PURPLE + REVERSE

	BRIGHT_WHITE    = WHITE + BRIGHT
	DIM_WHITE       = WHITE + DIM
	UNDERLINE_WHITE = WHITE + UNDERLINE
	REVERSE_WHITE   = WHITE + REVERSE

	BRIGHT_CYAN    = CYAN + BRIGHT
	DIM_CYAN       = CYAN + DIM
	UNDERLINE_CYAN = CYAN + UNDERLINE
	REVERSE_CYAN   = CYAN + REVERSE
)
View Source
const (
	// Unicode characters: http://graphemica.com/unicode/characters/page/34
	Ellipsis = string('\U00002026')
)
View Source
const GIGABYTE = (MEGABYTE * 1024)
View Source
const MEGABYTE = (1024 * 1024)

Variables

This section is empty.

Functions

func AvgMultipleTrackers

func AvgMultipleTrackers(trackers []*AvgTracker) float64

func CaseInsensitiveLess

func CaseInsensitiveLess(s1, s2 string) bool

func Format

func Format(n int64) string

func FormatDisplayData added in v0.7.1

func FormatDisplayData(value string, size int) string

TODO: Old API -- replaced by FormatDisplayDataLeft

func FormatDisplayDataLeft added in v0.7.9

func FormatDisplayDataLeft(value string, size int) string

func FormatDisplayDataRight added in v0.7.9

func FormatDisplayDataRight(value string, size int) string

func FormatIntDisplayData added in v0.7.9

func FormatIntDisplayData(value int, size int) string

func FormatUint64 added in v0.7.6

func FormatUint64(n uint64) string

func GetApiEndpointNoProtocol added in v0.7.6

func GetApiEndpointNoProtocol(cliConnection plugin.CliConnection) string

func Ip2long added in v0.7.3

func Ip2long(s string) (ret uint32)

func IsCygwin added in v0.6.4

func IsCygwin() bool

func IsMSWindows added in v0.6.4

func IsMSWindows() bool

func OrderedBy

func OrderedBy(less []LessFunc) *multiSorter

OrderedBy returns a Sorter that sorts using the less functions, in order. Call its Sort method to sort the data.

func Pseudo_uuid added in v0.7.6

func Pseudo_uuid() (uuid string)

Types

type AvgTracker

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

A RateCounter is a thread-safe counter which returns the number of times 'Incr' has been called in the last interval

func NewAvgTracker

func NewAvgTracker(intrvl time.Duration) *AvgTracker

Constructs a new RateCounter, for the interval provided

func (*AvgTracker) Avg

func (r *AvgTracker) Avg() float64

func (*AvgTracker) Rate

func (r *AvgTracker) Rate() int

Return the current number of events in the last interval

func (*AvgTracker) Track

func (r *AvgTracker) Track(val int64)

Add an event into the RateCounter

type ByteSize

type ByteSize float64
const (
	KB ByteSize = 1 << (10 * iota)
	MB
	GB
	TB
	PB
	EB
	ZB
	YB
)

func (ByteSize) String

func (b ByteSize) String() string

func (ByteSize) StringWithPrecision added in v0.7.0

func (b ByteSize) StringWithPrecision(precision int) string

type LessFunc

type LessFunc func(p1, p2 Sortable) bool

func Reverse

func Reverse(less LessFunc) LessFunc

type RateCounter

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

A RateCounter is a thread-safe counter which returns the number of times 'Incr' has been called in the last interval

func NewRateCounter

func NewRateCounter(interval time.Duration) *RateCounter

Constructs a new RateCounter, for the interval provided

func (*RateCounter) Incr

func (r *RateCounter) Incr()

Add an event into the RateCounter

func (*RateCounter) Rate

func (r *RateCounter) Rate() int

Return the current number of events in the last interval

type Sortable

type Sortable interface{}

Jump to

Keyboard shortcuts

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