Documentation ¶
Index ¶
- Constants
- Variables
- func BeginsWith(s, expr string) bool
- func Bool(v bool) *bool
- func ByteMap(m *map[string][]byte)
- func ConvTimeInLocation(t time.Time, local string) (time.Time, error)
- func Cyan(msg string) string
- func EndsWith(s, expr string) bool
- func ExitSignalHandler(onExit func())
- func FuncCaller() string
- func GetIniValueByKey(iniFile *ini.File, key string) (value string, err error)
- func GetRegexNamedGroups(text string, expression *regexp.Regexp) (map[string]string, error)
- func GetRegexPositionalGroups(text string, expression *regexp.Regexp) ([]string, error)
- func Green(msg string) string
- func IPAddress() (ipAddr string, err error)
- func InStringSlice(slice []string, value string) bool
- func Int32(v int32) *int32
- func Int64(v int64) *int64
- func InterfaceMapHash32(msg map[string]interface{}) (string, error)
- func IsRetryFailure(err error) bool
- func IsStringSliceEqual(slice1, slice2 []string) bool
- func IsSubnet(dstNetStr string, existNetStr string) (bool, error)
- func LOC() *time.Location
- func LOCWithName(name string) *time.Location
- func LoadIni(source interface{}) (iniFile *ini.File, err error)
- func MD5Hash(input string) string
- func Matches(s string, expr string) bool
- func Max(a, b uint64) uint64
- func Min(a, b uint64) uint64
- func ParseKVs(text string) (res map[string]string)
- func PrintFatalError(err error)
- func PrintMsg(msg string, strs ...string)
- func Red(msg string) string
- func Retry(interval time.Duration, maxRetries int, f ConditionFunc) error
- func SetColor(msg string, conf, bg, text int) string
- func SizeToBytes(s string) (uint64, error)
- func String(v string) *string
- func StringMap(m *map[string]string)
- func TimeParseInLocal(timeStr string) (*time.Time, error)
- func TimeParseInLocation(timeStr string, local string) (*time.Time, error)
- func ToUpperStringSlice(slice []string) []string
- func UnsafeMergeMap(tgt map[string]interface{}, src map[string]interface{}) map[string]interface{}
- func UnsafeMergeStringMap(tgt map[string]string, src map[string]string) map[string]string
- func ValidateCIDR(cidr string) bool
- func White(msg string) string
- func YamlToJSON(y string) (j string, err error)
- func Yellow(msg string) string
- type ConditionFunc
- type IDUtils
- type RetryError
Constants ¶
const ( TextBlack = iota + 30 TextRed TextGreen TextYellow TextBlue TextMagenta TextCyan TextWhite )
const ( KB uint64 = 1 << (10 * iota) MB GB )
Nolint: megacheck, deadcode, varcheck.
const FormatTime = "2006-01-02 15:04:05"
Variables ¶
var UUID = &IDUtils{}
Functions ¶
func BeginsWith ¶
BeginsWith returns true when a given expression is found at the start of the input string Unlike `strings.HasPrefix`, the expression can be a regular expression rather than a fixed string
func EndsWith ¶
EndsWith returns true when a given expression is found at the end of the input string Unlike `strings.HasSuffix`, the expression can be a regular expression rather than a fixed string
func ExitSignalHandler ¶
func ExitSignalHandler(onExit func())
func FuncCaller ¶
func FuncCaller() string
func GetIniValueByKey ¶
func GetRegexNamedGroups ¶
GetRegexNamedGroups returns the strings captured by a regular expression with named groups It returns an error when no named groups were in the regular expression It returns nil when the expression did not match
func GetRegexPositionalGroups ¶
GetRegexPositionalGroups returns the strings captured by a regular expression with positional groups It returns an error when named groups were in the regular expression It returns nil when the expression did not match
func InStringSlice ¶
func InterfaceMapHash32 ¶
func IsRetryFailure ¶
func IsStringSliceEqual ¶
func LOCWithName ¶
func LoadIni ¶
func LoadIni(source interface{}) (iniFile *ini.File, err error)
LoadIni load ini data sources. source arguments can be mixed of file name with string type, or raw data in []byte.
func PrintFatalError ¶
func PrintFatalError(err error)
func Retry ¶
func Retry(interval time.Duration, maxRetries int, f ConditionFunc) error
Retry retries f every interval until after maxRetries. The interval won't be affected by how long f takes. For example, if interval is 3s, f takes 1s, another f will be called 2s later. However, if f takes longer than interval, it will be delayed.
func SizeToBytes ¶
SizeToBytes parses a string formatted by ByteSize as bytes. K = 1024 M = 1024 * K G = 1024 * M
func TimeParseInLocation ¶
func ToUpperStringSlice ¶
func UnsafeMergeMap ¶
func UnsafeMergeStringMap ¶
func ValidateCIDR ¶
func YamlToJSON ¶
YamlToJSON converts yaml to json string
Types ¶
type ConditionFunc ¶
type RetryError ¶
type RetryError struct {
// contains filtered or unexported fields
}
func (*RetryError) Error ¶
func (e *RetryError) Error() string