utils

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(tb testing.TB, condition bool, msg string, v ...interface{})

Assert fails the test if the condition is false.

func Equals

func Equals(tb testing.TB, exp, act interface{})

Equals fails the test if exp is not equal to act.

func ErrorMsg

func ErrorMsg(id string)

ErrorMsg displays cute error ASCI Art for PID Errors

func GetDateFromUnix

func GetDateFromUnix(createTime int64) string

GetDateFromUnix gets a date and time in RFC822 format from a unix epoch in millisecond

func GetInMB

func GetInMB(bytes uint64, precision int) float64

GetInMB converts bytes to MB

func Raises

func Raises(tb testing.TB, err error)

Raises fails the test if an err is not nil.

func RoundFloat

func RoundFloat(num float64, base string, precision int) float64

RoundFloat rounds off a float to a given base and precision

func RoundUint

func RoundUint(num uint64, base string, precision int) float64

RoundUint rounds a float by making use of RoundFloat

func RoundValues

func RoundValues(num1, num2 float64, inBytes bool) ([]float64, string)

RoundValues rounds off values to nearest K, G, M, etc. Returns the rounded values and the unit. If inBytes is set to true, units are returned as B, kB, gB, etc.

func SecondsToHuman

func SecondsToHuman(input int) (result string)

SecondsToHuman converts a given UNIX epoch in seconds to human readble format

func SortData

func SortData(data [][]string, sortIdx int, sortAsc bool, sortCase string)

SortData helps sort table rows. It sorts the table based on values given in the sortIdx column and sorts ascending if sortAsc is true. sortCase is set to identify the set of 'less' functions to use to sort the selected column by.

func TickUntilDone

func TickUntilDone(ctx context.Context, refreshRate uint64, action func() error) (err error)

TickUntilDone runs a given action at a tick rate specified by refreshRate, it returns if the context is cancelled

func Trim

func Trim(num float64, precision int) float64

Trim trims a float to the specified number of precision decimal digits.

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