util

package
v0.0.0-...-20aa718 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseDecimal = 1000.0
	BaseBinary  = 1024.0
)

Multiplier value

View Source
const (
	BYTE = iota
	KILO
	MEGA
	GIGA
	TERA
	PETA
	EXA
	ZETTA
	YOTTA
)

Units value

Variables

This section is empty.

Functions

func BlkLabelAscSorter

func BlkLabelAscSorter(a, b string) bool

BlkLabelAscSorter is the sorter for sort.Slice() to sort block device labels by asc

func BytesToUint32

func BytesToUint32(b []byte) uint32

BytesToUint32 converts []byte to uint32

func BytesToUint64

func BytesToUint64(b []byte) uint64

BytesToUint64 converts []byte to uint64

func CastToFloat64

func CastToFloat64(value interface{}) (float64, error)

CastToFloat64 converts the given value to float64

func ConvUnit

func ConvUnit(value float64, mlt float64, target float64, fit bool) (string, error)

ConvUnit returns the string representation of value in given base with given unit. The unit will be optimized automatically if fit is true.

func ConvUnitBin

func ConvUnitBin(value interface{}, target float64) (string, error)

ConvUnitBin returns the string representation of value in 1024 base with given unit.

func ConvUnitBinFit

func ConvUnitBinFit(value interface{}, target float64) (string, error)

ConvUnitBinFit returns the string representation of value in 1024 base with given unit. The unit will be optimized automatically.

func ConvUnitDec

func ConvUnitDec(value interface{}, target float64) (string, error)

ConvUnitDec returns the string representation of value in 1000 base with given unit.

func ConvUnitDecFit

func ConvUnitDecFit(value interface{}, target float64) (string, error)

ConvUnitDecFit returns the string representation of value in 1000 base with given unit. The unit will be optimized automatically.

func DumpBinary

func DumpBinary(in interface{}) string

DumpBinary returns the string that represents the value as binary array

func Exec

func Exec(c string, arg ...string) (string, error)

Exec runs specified command and returns output as string

func Executable

func Executable(path string) bool

Executable returns if the file named by path is executable

func Exists

func Exists(path string) bool

Exists returns if the file named by path exists

func FilterFiles

func FilterFiles(path string, filter func(os.FileInfo) bool) []string

FilterFiles returns filtered items by filter function

func FilterPrefixedDirs

func FilterPrefixedDirs(path, prefix string) []string

FilterPrefixedDirs returns filtered directories which has given prefix

func FilterPrefixedFiles

func FilterPrefixedFiles(path, prefix string) []string

FilterPrefixedFiles returns filtered regular files which has given prefix

func FilterPrefixedLinks(path, prefix string) []string

FilterPrefixedLinks returns filtered symlinks which has given prefix

func FindMSB

func FindMSB(b interface{}) (int, error)

FindMSB returns most significant bit position in given value

func HasPrefixIn

func HasPrefixIn(l string, ptns ...string) bool

HasPrefixIn returns true if given string has one of prefix

func IPv4MaskSize

func IPv4MaskSize(mask string) int

IPv4MaskSize returns mask size of given string representation

func LoadByte

func LoadByte(path string) (byte, error)

LoadByte reads the file named by path and returns the contents as byte(uint8)

func LoadBytes

func LoadBytes(path string) ([]byte, error)

LoadBytes reads the file named by path and returns the contents as []byte

func LoadString

func LoadString(path string) (string, error)

LoadString reads the file named by path and returns the contens as string

func LoadUint16

func LoadUint16(path string) (uint16, error)

LoadUint16 reads the file named by path and returns the contents as uint16

func LoadUint32

func LoadUint32(path string) (uint32, error)

LoadUint32 reads the file named by path and returns the contents as uint32

func LoadUint64

func LoadUint64(path string) (uint64, error)

LoadUint64 reads the file named by path and returns the contents as uint64

func Round

func Round(f float64, pt int) float64

Round returns rounded floting value

func SanitizeString

func SanitizeString(str string) string

SanitizeString returns string with all unuseful words

func ScanPathList

func ScanPathList(list []string) (string, error)

ScanPathList returns path which was found by firtst from the list

func ShortenProcName

func ShortenProcName(str string) string

ShortenProcName returns short version processor name

func ShortenVendorName

func ShortenVendorName(str string) string

ShortenVendorName returns short version vendor name

Types

This section is empty.

Jump to

Keyboard shortcuts

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