Documentation
¶
Overview ¶
Package utils provides utility functions for handling common tasks such as setting default values, checking 'zero-ness', and normalizing map keys. Includes string comparison functions and map merging functions.
Index ¶
- func DeepMergeMapsWithoutOverwrite(first, second map[string]any)
- func IsURL(str string) bool
- func IsZeroValue[S comparable](input S) bool
- func NormalizeMap(m map[string]any) map[string]any
- func SetIfZeroValue[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 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 IsZeroValue ¶ added in v0.0.1
func IsZeroValue[S comparable](input S) bool
IsZeroValue checks if the input value is its zero value.
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 SetIfZeroValue ¶ added in v0.0.1
func SetIfZeroValue[S comparable](input *S, value S)
SetIfZeroValue sets the value of input to the specified value if it is its zero value.
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.
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.
Types ¶
This section is empty.