utl

package module
v1.1.12 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: MIT Imports: 18 Imported by: 1

README

utl

Common utilities housekeeping functions

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Red = color.FgLightRed.Render
	Blu = color.FgLightBlue.Render
	Gre = color.FgGreen.Render
	Yel = color.FgYellow.Render
	Whi = color.FgWhite.Render
	Cya = color.FgCyan.Render
	Mag = color.FgLightMagenta.Render
	Gra = color.FgDarkGray.Render

	Red2 = color.FgRed.Render
	Blu2 = color.FgBlue.Render
	Gre2 = color.FgLightGreen.Render
	Yel2 = color.FgLightYellow.Render
	Whi2 = color.FgLightWhite.Render
	Cya2 = color.FgLightCyan.Render
	Mag2 = color.FgMagenta.Render
)

Functions

func BytesToYamlObject added in v1.1.9

func BytesToYamlObject(yamlBytes []byte) (yamlObject interface{}, err error)

func ConvertDateFormat added in v1.1.2

func ConvertDateFormat(dateString, srcFormat, dstFormat string) (string, error)

func DateStringToEpocInt64 added in v1.1.2

func DateStringToEpocInt64(dateString, dateFormat string) (int64, error)

func Die

func Die(format string, args ...interface{})

func EpocInt64ToTime added in v1.1.8

func EpocInt64ToTime(epocInt int64) time.Time

func EpocStringToTime added in v1.1.2

func EpocStringToTime(epocString string) (time.Time, error)

func FileExist

func FileExist(filePath string) (e bool)

func FileModTime

func FileModTime(filePath string) int

func FileNotExist

func FileNotExist(filePath string) (e bool)

func FileSize

func FileSize(filePath string) int64

func FileUsable

func FileUsable(filePath string) (e bool)

func FirstN added in v1.1.3

func FirstN(s string, n int) string

func GetDateInDays added in v1.1.8

func GetDateInDays(days string) time.Time

func GetDaysBetween added in v1.1.8

func GetDaysBetween(date1, date2 string) int64

func GetDaysSinceOrTo added in v1.1.8

func GetDaysSinceOrTo(date1 string) int64

func GetType added in v1.0.0

func GetType(v interface{}) string

func Int64Abs added in v1.1.8

func Int64Abs(x int64) int64

func Int64ToString added in v1.1.8

func Int64ToString(i int64) string

func IntAbs added in v1.1.2

func IntAbs(x int) int

func IsAlpha added in v1.1.12

func IsAlpha(c rune) bool

func IsDigit added in v1.1.12

func IsDigit(c rune) bool

func IsHexDigit added in v1.0.6

func IsHexDigit(c rune) bool

func IsIpPortStrReachable added in v1.1.12

func IsIpPortStrReachable(ipPortStr string) bool

func IsLeapYear added in v1.1.8

func IsLeapYear(year int64) bool

func ItemInList

func ItemInList(arg string, argList []string) bool

func JsonBytesReindent added in v1.1.9

func JsonBytesReindent(jsonBytes []byte, indent int) (jsonBytes2 []byte, err error)

func JsonToBytes added in v1.1.9

func JsonToBytes(jsonObject interface{}) (jsonBytes []byte, err error)

func JsonToBytesIndent added in v1.1.9

func JsonToBytesIndent(jsonObject interface{}, indent int) (jsonBytes []byte, err error)

func LastElem

func LastElem(s, splitter string) string

func LoadFileJson

func LoadFileJson(filePath string) (jsonObject interface{}, err error)

func LoadFileYaml

func LoadFileYaml(filePath string) (yamlObject interface{}, err error)

func LoadFileYamlBytes added in v1.1.8

func LoadFileYamlBytes(filePath string) (yamlBytes []byte, err error)

func MergeMaps

func MergeMaps(m1, m2 map[string]string) (result map[string]string)

func MergeObjects

func MergeObjects(x, y map[string]interface{}) (obj map[string]interface{})

func PadSpaces

func PadSpaces(targetWidth, stringWidth int) string

func PostSpc added in v1.1.11

func PostSpc(value interface{}, width int) string

func PreSpc added in v1.1.11

func PreSpc(value interface{}, width int) string

func Prettify

func Prettify(jsonObject interface{}) (pretty string, err error)

func PrintColorSamples added in v1.0.14

func PrintColorSamples()

func PrintDays added in v1.1.2

func PrintDays(days int64)

func PrintJson

func PrintJson(jsonObject interface{})

func PrintJsonBytesColor added in v1.1.9

func PrintJsonBytesColor(jsonBytes []byte)

func PrintJsonColor added in v1.1.9

func PrintJsonColor(jsonObject interface{})

func PrintYaml

func PrintYaml(yamlObject interface{})

func PrintYamlBytesColor added in v1.1.8

func PrintYamlBytesColor(yamlBytes []byte)

func PrintYamlColor added in v1.1.8

func PrintYamlColor(yamlObject interface{})

func PromptMsg added in v1.0.13

func PromptMsg(msg string) rune

func RemoveFile

func RemoveFile(filePath string)

func SameType

func SameType(a, b interface{}) bool

func SaveFileJson

func SaveFileJson(jsonObject interface{}, filePath string)

func SaveFileYaml

func SaveFileYaml(yamlObject interface{}, filePath string)

func SortMapStringKeys added in v1.1.1

func SortMapStringKeys(obj map[string]string) (sortedKeys []string)

TODO: Combine below two func with interfaces

func SortObjStringKeys added in v1.1.1

func SortObjStringKeys(obj map[string]interface{}) (sortedKeys []string)

func Str added in v1.0.2

func Str(x interface{}) string

func StringToInt64 added in v1.1.2

func StringToInt64(s string) (int64, error)

func SubString

func SubString(large, small string) bool

func ToStr added in v1.1.11

func ToStr(value interface{}) string

func Trace

func Trace() string

func ValidDate added in v1.1.4

func ValidDate(dateString, expectedFormat string) bool

func ValidIpStr added in v1.1.12

func ValidIpStr(ipStr string) bool

func ValidUuid

func ValidUuid(s string) bool

func YamlToBytes added in v1.1.9

func YamlToBytes(yamlObject interface{}) (yamlBytes []byte, err error)

func YamlToBytesIndent added in v1.1.9

func YamlToBytesIndent(yamlObject interface{}, indent int) (yamlBytes []byte, err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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