util

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2022 License: Apache-2.0 Imports: 9 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUniqueStringtoSlice added in v0.8.0

func AddUniqueStringtoSlice(names []string, name string) []string

AddUniqueStringtoSlice ensures there are no repeated devices added to a slice

func CheckErr

func CheckErr(err error, handleErr func(string))

CheckErr to handle command errors

func CheckFalsy

func CheckFalsy(falsy string) bool

CheckFalsy checks for non-truthiness of the passed argument.

func CheckTruthy

func CheckTruthy(truth string) bool

CheckTruthy checks for truthiness of the passed argument.

func Contains

func Contains(s []string, k string) bool

Contains is a util function which returns true if one key is present in array else it returns false

func ContainsIgnoredCase

func ContainsIgnoredCase(s []string, k string) bool

ContainsIgnoredCase is a util function which returns true if one key is present in array else it returns false. This function is not case sensitive.

func FD_ISSET

func FD_ISSET(p *syscall.FdSet, i int) bool

FD_ISSET tests to see if a file descriptor is part of the set

func FD_SET

func FD_SET(p *syscall.FdSet, i int)

FD_SET add a given file descriptor from a set it perform bit shift operations and set fdset. ie if value of i is 2 then it will set fdset's value as {[16]int64{4}}

func FD_ZERO

func FD_ZERO(p *syscall.FdSet)

FD_ZERO clears a set it perform bit shift operations and clear fdset.

func Fatal

func Fatal(msg string)

Fatal prints the message (if provided) and then exits. If V(2) or greater, klog.Fatal is invoked for extended information.

func Hash

func Hash(s string) string

Hash retrieves an encoded string using the md5 encrypt

func IsMatchRegex added in v0.4.0

func IsMatchRegex(regex, s string) bool

IsMatchRegex is a utility function which returns true if the string -s matches with the regex specified.

func MatchIgnoredCase

func MatchIgnoredCase(keys []string, s string) bool

MatchIgnoredCase is a util function which returns true if any of the keys are present as a string in given string - s This function is not case sensitive.

func RemoveString added in v0.4.0

func RemoveString(slice []string, s string) (result []string)

RemoveString removes all occurrences of a string from slice

func SparseFileCreate

func SparseFileCreate(path string, size int64) error

SparseFileCreate will create a new sparse file if none exists at the give path and will set the size to specified value

func SparseFileDelete

func SparseFileDelete(path string) error

SparseFileDelete will delete the sparse file if it exists

func SparseFileInfo

func SparseFileInfo(path string) (os.FileInfo, error)

SparseFileInfo will return the stats of the sparse file

func StateStatus

func StateStatus(state bool) string

StateStatus returns enable if state is true and disable if state is false

func StrToInt32

func StrToInt32(val string) *int32

StrToInt32 converts a string type to corresponding *int32 type

NOTE:

This swallows the error if any

func StringToInt32

func StringToInt32(val string) (*int32, error)

StringToInt32 converts a string type to corresponding *int32 type

Types

This section is empty.

Jump to

Keyboard shortcuts

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