Documentation
¶
Index ¶
- func ArrayAdd[TValue any](arr []TValue, val TValue) []TValue
- func ArrayAddRange[TItem any](list []TItem, items []TItem) []TItem
- func ArrayCut[TValue any](arr []TValue, startIndex int, endIndex int) []TValue
- func ArrayExists[TValue any](arr []TValue, matcher func(TValue) bool) bool
- func ArrayFilter[TInput any, TResult any](items []TInput, test func(TInput) (TResult, bool)) []TResult
- func ArrayOfStringToInt(sArr []string) []int
- func ArrayPop[TValue any](arr []TValue) ([]TValue, TValue)
- func ArrayRemove[TValue any](arr []TValue, index int) []TValue
- func ArrayRemoveFast[TValue any](s []TValue, index int) []TValue
- func ArrayReverse[TValue any](arr []TValue) []TValue
- func ArraySplit[TItem any](list []TItem, max int) map[int][]TItem
- func ArraySurroundWith(arr []string, char string) []string
- func ArrayToArrayGroups[TItem any, TOutput any](arr []TItem, count int, selector FuncSelector[TItem, TOutput]) [][]TOutput
- func ArrayToCommaString[TItem int | int32 | int64](list []TItem, approxLen int) string
- func ArrayToMap[TItem any, TKey int | int8 | int32 | int16 | int64 | string, TOutput any](arr []TItem, keySelector FuncSelector[TItem, TKey], ...) map[TKey]TOutput
- func ArrayToMapIgnore[TItem any, TKey int | int8 | int32 | int16 | int64 | string, TOutput any](arr []TItem, keySelector FuncSelector[TItem, TKey], ...) map[TKey]TOutput
- func ArrayToMapList[TItem any, TKey int | int8 | int32 | int16 | int64 | string, TOutput any](arr []TItem, keySelector FuncSelector[TItem, TKey], ...) map[TKey][]TOutput
- func ArrayUnique[TKey int | int8 | int32 | int16 | int64 | string, TValue any](arr []TValue, keySelector func(TValue) TKey) []TValue
- func CloneMap[Key int | string, Value any](this map[Key]Value) map[Key]Value
- func ConvertToArray[TItem any, TOutput any](arr []TItem, selector FuncSelector[TItem, TOutput]) []TOutput
- func Cut(val string, length int) string
- func Float32ToString(num float32) string
- func Float64ToString(num float64) string
- func Ifi[TVal any](x bool, t TVal, f TVal) TVal
- func Iif[TVal any](x bool, t TVal, f TVal) TVal
- func Int32ToString(num int32) string
- func Int64ToString(num int64) string
- func IntToString(num int) string
- func MapAddOrUpdate[TKey int | int8 | int32 | int16 | int64 | string, TValue any](this map[TKey]TValue, key TKey, val TValue) map[TKey]TValue
- func MapArrayAdd[TKey int | int8 | int32 | int16 | int64 | string, TValue any](this map[TKey][]TValue, key TKey, val TValue) map[TKey][]TValue
- func MapKeyExists[TKey int | int8 | int32 | int16 | int64 | string, TValue any](this map[TKey]TValue, key TKey, def TValue) (bool, TValue)
- func MapToArray[TKey int | int8 | int32 | int16 | int64 | string, TValue any](this map[TKey]TValue) []TValue
- func ParseDuration(value string, def time.Duration) time.Duration
- func SplitFloat32(num float32) (int32, int32, error)
- func SplitFloat32WithPrecision(num float32, prec int) (int32, int32, error)
- func SplitFloat64(num float64) (int64, int64, error)
- func SplitFloat64WithPrecision(num float64, prec int) (int64, int64, error)
- func StripAnsiColors(str string) string
- func TimeWithOffsetFromLocal(input time.Time, location *time.Location) time.Time
- func TimeWithoutOffsetFromUTC(input time.Time, location *time.Location) time.Time
- func WorkingDir() string
- type FuncSelector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayAdd ¶
func ArrayAdd[TValue any](arr []TValue, val TValue) []TValue
ArrayAdd adds the value to the array
func ArrayAddRange ¶
func ArrayAddRange[TItem any](list []TItem, items []TItem) []TItem
ArrayAddRange adds a range of elements to the array
func ArrayCut ¶
ArrayCut returns a section of the original array between and including the 'startIndex' and excludes the 'endIndex'
func ArrayExists ¶
ArrayExists return true if the 'matcher' function return true on any of the values
func ArrayFilter ¶
func ArrayFilter[TInput any, TResult any](items []TInput, test func(TInput) (TResult, bool)) []TResult
ArrayFilter returns a new array with the elements that match the 'test'
func ArrayOfStringToInt ¶
ArrayOfStringToInt tries to convert every value in the array to and int, it will panic if a convertion failes
func ArrayPop ¶
func ArrayPop[TValue any](arr []TValue) ([]TValue, TValue)
ArrayPop removes the first element from the array and return the new array and the value popped
func ArrayRemove ¶
ArrayRemove removes the index from the array and keeps the order of elements
func ArrayRemoveFast ¶
ArrayRemoveFast removes the index from the array, but the order of elements are not kept
func ArrayReverse ¶
func ArrayReverse[TValue any](arr []TValue) []TValue
ArrayReverse returns the array in opposite order
func ArraySplit ¶
ArraySplit splits the array into groups of max items defined by 'max'
func ArraySurroundWith ¶
ArraySurroundWith updates the array and puts the specified characters in front and behind each value in the array
func ArrayToArrayGroups ¶
func ArrayToArrayGroups[TItem any, TOutput any](arr []TItem, count int, selector FuncSelector[TItem, TOutput]) [][]TOutput
ArrayToArrayGroups convert an array of type 'TItem' into a 2-dim array of group with defined count
func ArrayToCommaString ¶
ArrayToCommaString converts an array of numbers to a comma separated string for use in sqls 'where in' statement
func ArrayToMap ¶
func ArrayToMap[TItem any, TKey int | int8 | int32 | int16 | int64 | string, TOutput any](arr []TItem, keySelector FuncSelector[TItem, TKey], valueSelector FuncSelector[TItem, TOutput]) map[TKey]TOutput
ArrayToMap converts an array of type 'TItem' into a map on the value returned by 'keySelector'
func ArrayToMapIgnore ¶
func ArrayToMapIgnore[TItem any, TKey int | int8 | int32 | int16 | int64 | string, TOutput any](arr []TItem, keySelector FuncSelector[TItem, TKey], valueSelector FuncSelector[TItem, TOutput], ignoreKeyMatcher FuncSelector[TItem, bool]) map[TKey]TOutput
ArrayToMapIgnore converts an array of type 'TItem' into a map on the value returned by 'keySelector', but ignores the key if 'ignoreKeyMatcher' returns true
func ArrayToMapList ¶
func ArrayToMapList[TItem any, TKey int | int8 | int32 | int16 | int64 | string, TOutput any](arr []TItem, keySelector FuncSelector[TItem, TKey], valueSelector FuncSelector[TItem, TOutput]) map[TKey][]TOutput
ArrayToMapList converts an array of type 'TItem' into a map with array grouped on the value returned by 'keySelector'
func ArrayUnique ¶
func ArrayUnique[TKey int | int8 | int32 | int16 | int64 | string, TValue any](arr []TValue, keySelector func(TValue) TKey) []TValue
ArrayUnique returns a new array with only the unique values based on the result of 'keySelector'
func ConvertToArray ¶
func ConvertToArray[TItem any, TOutput any](arr []TItem, selector FuncSelector[TItem, TOutput]) []TOutput
ConvertToArray converts one array of type 'TItem' into a new array of type 'TOutput'
func Float32ToString ¶
Float32ToString converts 'num' into a base(10) string of the number
func Float64ToString ¶
Float64ToString converts 'num' into a base(10) string of the number
func Int32ToString ¶
Int32ToString converts 'num' into a base(10) string of the number
func Int64ToString ¶
Int64ToString converts 'num' into a base(10) string of the number
func IntToString ¶
IntToString converts 'num' into a base(10) string of the number
func MapAddOrUpdate ¶
func MapAddOrUpdate[TKey int | int8 | int32 | int16 | int64 | string, TValue any](this map[TKey]TValue, key TKey, val TValue) map[TKey]TValue
MapAddOrUpdate updates the 'key' with the 'value' if it already exists, else it will add the value to the map
func MapArrayAdd ¶
func MapArrayAdd[TKey int | int8 | int32 | int16 | int64 | string, TValue any](this map[TKey][]TValue, key TKey, val TValue) map[TKey][]TValue
MapArrayAdd adds 'value' to the array of the 'key' in the map
func MapKeyExists ¶
func MapKeyExists[TKey int | int8 | int32 | int16 | int64 | string, TValue any](this map[TKey]TValue, key TKey, def TValue) (bool, TValue)
MapKeyExists returns true and the value if the 'key' exists in the map
func MapToArray ¶
func MapToArray[TKey int | int8 | int32 | int16 | int64 | string, TValue any](this map[TKey]TValue) []TValue
MapToArray returns an array of each of the values in the map
func ParseDuration ¶
ParseDuration takes a duration string representation and converts it into a time.Duration, or returns the 'def' if it fails Examples such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
func SplitFloat32 ¶
SplitFloat32 tries to split a 'num' into its two components the number and precision, or an error if it fails
func SplitFloat32WithPrecision ¶
SplitFloat32WithPrecision tries to split a 'num' into its two components the number and precision, 'prec' can be used to define the precision (number of decimals), or an error if it fails
func SplitFloat64 ¶
SplitFloat64 tries to split a 'num' into its two components the number and precision, or an error if it fails
func SplitFloat64WithPrecision ¶
SplitFloat64WithPrecision tries to split a 'num' into its two components the number and precision, 'prec' can be used to define the precision (number of decimals), or an error if it fails
func StripAnsiColors ¶
StripAnsiColors strips all ansi color values from a string
func TimeWithOffsetFromLocal ¶
TimeWithOffsetFromLocal returns the 'input' time with an offset of the defined 'location'
func TimeWithoutOffsetFromUTC ¶
TimeWithoutOffsetFromUTC returns the 'input' time without offset from utc
func WorkingDir ¶
func WorkingDir() string
WorkingDir tries to get the correct path of the current execution based on the value of the ENV environment variable. if the ENV is debug, then it wil used os.Getwd() else it will use filepath.Dir(os.Executable())