Documentation
¶
Overview ¶
Package utils provides utility functions for handling common tasks such as setting default values, checking emptiness, and normalizing map keys. Includes string comparison functions and map merging functions.
Index ¶
- func ContainsLower(a, b string) bool
- func DeepMergeMapsWithoutOverwrite(first, second map[string]any)
- func EqualLower(a, b string) bool
- func IsEmpty[S comparable](input S) bool
- func IsURL(str string) bool
- func NormalizeMap(m map[string]any) map[string]any
- func SetIfEmpty[S comparable](input *S, value S)
- func SetMapIfNil[M ~map[K]V, K comparable, V any](input *M, values M)
- func SetSliceIfNil[S ~[]T, T any](input *S, values ...T)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsLower ¶
ContainsLower checks if string 'a' contains string 'b' case-insensitively.
func DeepMergeMapsWithoutOverwrite ¶
DeepMergeMapsWithoutOverwrite merges two maps of map[string]any, adding values from second to first without overwriting the existing values in first. It performs a deep merge, handling nested maps recursively.
func EqualLower ¶
Equal compares two strings case-insensitively and returns true if they are equal.
func IsEmpty ¶
func IsEmpty[S comparable](input S) bool
IsEmpty checks if the input value is empty. S must be a comparable type.
func NormalizeMap ¶
NormalizeMap normalizes the keys of a map to title case recursively. If the value is another map, it will recursively normalize its keys as well.
func SetIfEmpty ¶
func SetIfEmpty[S comparable](input *S, value S)
SetIfEmpty sets the value of input to the specified value if it is empty. S must be a comparable type.
func SetMapIfNil ¶
func SetMapIfNil[M ~map[K]V, K comparable, V any](input *M, values M)
SetMapIfNil sets the value of input to the provided defaultMap if input is nil. M is constrained to maps with keys of type K and values of type V.
func SetSliceIfNil ¶
func SetSliceIfNil[S ~[]T, T any](input *S, values ...T)
SetSliceIfNil sets the value of input to the provided values slice if input is nil. S is constrained to slices of any type T.
Types ¶
This section is empty.