Documentation
¶
Index ¶
- func Equal[C comparable](v C, values ...C) bool
- func FieldTagNames(fields []*structs.Field, tag string) (names []string)
- func FirstNonEmpty[C comparable](possibleValues ...C) C
- func IsMap(v interface{}) bool
- func IsSlice(v interface{}) bool
- func MapKeys[M ~map[K]V, K comparable, V any](m M) []K
- func MergeMaps(overwrite bool, mm ...map[string]any) map[string]any
- func NewInt(i int) *int
- func NilAllExceptByTag(v interface{}, jsonTags []string)
- func ReflectIntersect(a, b any) any
- func ReflectIsSubsetOf(is, of any) bool
- func ReflectIsSupersetOf(is, of any) bool
- func ReflectSliceCast(slice, newType any) any
- func ReflectSliceContains(v, slice any) bool
- func ReflectUnion(a, b any) any
- func RemoveFromSlice[C comparable](slice []C, v C) []C
- func SliceContains[C comparable](v C, slice []C) bool
- func SliceEqual(a, b interface{}) bool
- func Slicify(in any) any
- func StringsEqualIfSet(a, b string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equal ¶
func Equal[C comparable](v C, values ...C) bool
Equal compares multiple comparable values for equality
func FieldTagNames ¶
FieldTagNames returns a slice of the tag names for a []*structs.Field and the given tag
func FirstNonEmpty ¶
func FirstNonEmpty[C comparable](possibleValues ...C) C
FirstNonEmpty is a utility function returning the first of the passed values that is not empty/zero
func IsMap ¶
func IsMap(v interface{}) bool
IsMap uses reflection to check if an interface{} is a map
func IsSlice ¶
func IsSlice(v interface{}) bool
IsSlice uses reflection to check if an interface{} is a slice
func MapKeys ¶
func MapKeys[M ~map[K]V, K comparable, V any](m M) []K
MapKeys returns the keys of the map m. The keys will be an indeterminate order.
func MergeMaps ¶
MergeMaps merges two or more maps into on; overwrite determines if values are overwritten if already set or not
func NilAllExceptByTag ¶
func NilAllExceptByTag(v interface{}, jsonTags []string)
NilAllExceptByTag sets all fields of a struct to their zero values except for the fields with the specified JSON tags.
func ReflectIntersect ¶
ReflectIntersect uses reflection to compute the intersection of two slices
func ReflectIsSubsetOf ¶
ReflectIsSubsetOf uses reflection to check if a slice is a subset of another
func ReflectIsSupersetOf ¶
ReflectIsSupersetOf uses reflection to check if a slice is a superset of another
func ReflectSliceCast ¶
ReflectSliceCast casts a slice to another type using reflection
func ReflectSliceContains ¶
ReflectSliceContains checks if a slice contains a value using reflection
func ReflectUnion ¶
ReflectUnion uses reflection to compute the union of two slices
func RemoveFromSlice ¶
func RemoveFromSlice[C comparable](slice []C, v C) []C
RemoveFromSlice removes an element from the slice
func SliceContains ¶
func SliceContains[C comparable](v C, slice []C) bool
SliceContains checks if a slice contains a value
func SliceEqual ¶
func SliceEqual(a, b interface{}) bool
SliceEqual uses reflection to check if two slices contain the same elements; order does not matter, assumes no duplicate entries in a slice
func Slicify ¶
Slicify checks if an interface{} is a slice and if not returns a slice of the same type (as an interface{}) containing the value, otherwise it returns the original slice
func StringsEqualIfSet ¶
StringsEqualIfSet checks if two strings are equal if they are both not empty
Types ¶
This section is empty.