util

package
v3.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommonInitialization

func CommonInitialization()

func ConfigureViper

func ConfigureViper()

func DecodeGob

func DecodeGob(e interface{}, b []byte) error

func DoMemoryProfile added in v3.0.3

func DoMemoryProfile()

func DumpLine

func DumpLine(lst []string) string

DumpLine replaces empty string by None, join the slice and append newline

func DumpLines

func DumpLines(lst []string) []string

func EncodeToFile

func EncodeToFile(data interface{}, filePath string) error

func FatalIf

func FatalIf(err error)

FatalIf exits if the error is not nil

func FileExists

func FileExists(filePath string) bool

func FormatCompletion

func FormatCompletion(lines []string) string

func GetFromHttpServer

func GetFromHttpServer(url string) (http.Header, []byte, error)

func HeadFromHttpServer

func HeadFromHttpServer(url string) (http.Header, error)

func IsAddressReachable

func IsAddressReachable(address string) bool

func IsCharIn

func IsCharIn(c byte, slice []byte) bool

func IsStringExcluded

func IsStringExcluded(s string, regexps []*regexp.Regexp) bool

IsStringExcluded returns true if one of the regexp match the input string

func IsStringIn

func IsStringIn(element string, slice []string) bool

func IsStringIncluded

func IsStringIncluded(s string, regexps []*regexp.Regexp) bool

IsStringIncluded returns true if one of the regexp match the input string

func IsStringMatching

func IsStringMatching(s string, regexps []*regexp.Regexp) bool

func JoinSlicesOrNone

func JoinSlicesOrNone(sl []string, sep string) string

JoinSlicesOrNone joins a slice of string with separator or display None if there's no elements

func JoinSlicesWithMaxOrNone

func JoinSlicesWithMaxOrNone(sl []string, max int, sep string) string

JoinSlicesWithMaxOrNone joins a slice of string with separator up to x elements. Display None if there's no elements

func JoinStringMap

func JoinStringMap(m map[string]string, exclude map[string]string, sep string) []string

JoinStringMap generates a list of map element separated by string excluding keys in excluded maps

func LastURLPart

func LastURLPart(url string) string

LastURLPart extracts the last part of the url

func LoadGobFromFile

func LoadGobFromFile(e interface{}, filePath string) error

func ParseTimestamp

func ParseTimestamp(s string) (time.Time, error)

func RemoveTempDir

func RemoveTempDir(tempDir string)

func SetCommonCliFlags

func SetCommonCliFlags(fs *pflag.FlagSet, defaultLogLevel string)

func StringMapsEqual

func StringMapsEqual(a map[string]string, b map[string]string) bool

StringMapsEqual returns true if maps are equals

func StringSliceToRegexps

func StringSliceToRegexps(s []string) ([]*regexp.Regexp, error)

func StringSliceToSet

func StringSliceToSet(lst []string) map[string]bool

StringSliceToSet converts a string slice to a set like map

func StringSlicesEqual

func StringSlicesEqual(a []string, b []string) bool

StringSlicesEqual returns true if slices are equals

func TimeToAge

func TimeToAge(t time.Time) string

TimeToAge converts a time to a age string

func TruncateString

func TruncateString(s string, max int) string

TruncateString truncates a string to a given maximum

Types

type LogConf

type LogConf struct {
	LogLevel logrus.Level
}

Jump to

Keyboard shortcuts

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