util

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyNotNil added in v0.2.0

func AnyNotNil(values ...interface{}) bool

func GetBool

func GetBool(value bool, defaultValue bool) bool

Returns the true if value or defaultValue are true

func GetFloat

func GetFloat(values ...float64) float64

Returns the first non-zero float

func GetFloatPtr added in v0.1.1

func GetFloatPtr(values ...*float64) *float64

func GetIndexOrDefault added in v0.2.0

func GetIndexOrDefault[T any](nodes []T, index int, defaultItem T) T

func GetInt

func GetInt(values ...int) int

Returns the first non-zero int

func GetObjectKeyOrDefault added in v0.2.0

func GetObjectKeyOrDefault[T any](obj *map[string]T, key string, defaultItem T) T

GetObjectKeyOrDefault returns the value for the given key in the map or the defaultItem if the key does not exist or the map itself is nil

func GetPtr added in v0.2.0

func GetPtr[T any](values ...*T) *T

func GetString

func GetString(values ...string) string

Returns the first non-empty string

func GetValue added in v0.2.0

func GetValue(values ...interface{}) interface{}

func GetZeroIfNil added in v0.2.0

func GetZeroIfNil[T any](f *T, zeroValue T) T

func ImplodeMapStrings added in v0.2.0

func ImplodeMapStrings[V any](mapKeys map[string]V) string

func MapKeysToStringSlice added in v0.2.0

func MapKeysToStringSlice[T any](maps ...*map[string]T) []string

Extract the keys from a map[string]T as a []string

func MarshalJsonToString added in v0.2.0

func MarshalJsonToString(data interface{}) string

Marshal Data to a string in error cases the string is empty and the error is blackholed

func MaxFloatPtr added in v0.2.0

func MaxFloatPtr[T Number](a ...*T) *T

func MaxInt

func MaxInt(a ...int) int

MaxInt returns the highest value int in a variadic list of ints

func MergeSlicePtrs added in v0.2.0

func MergeSlicePtrs[T any](slices ...*[]T) *[]T

func MinFloatPtr added in v0.2.0

func MinFloatPtr[T Number](a ...*T) *T

MinFloatPtr returns the lowest value float pointer

func MinInt

func MinInt(a ...int) int

MinInt returns the lowest value int in a variadic list of ints

func MultiplyIfPossibleAndNotMultipleOfFloat64 added in v0.2.1

func MultiplyIfPossibleAndNotMultipleOfFloat64(a *float64, b *float64) *float64

func RegexMatchNamedCaptureGroups added in v0.2.0

func RegexMatchNamedCaptureGroups(r *regexp.Regexp, str string) map[string]string

Regex to named capture groups

func Round added in v0.1.1

func Round(x, unit float64) float64

func SafeMarshalListToJsonList added in v0.2.0

func SafeMarshalListToJsonList(data *[]interface{}) []string

func UnmarshalJsonStringToMap added in v0.2.0

func UnmarshalJsonStringToMap(data string) interface{}

Unmarshal a string to a map

Types

type Number added in v0.2.1

type Number interface {
	constraints.Integer | constraints.Float
}

Jump to

Keyboard shortcuts

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