utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

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

func FieldTagNames(fields []*structs.Field, tag string) (names []string)

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

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 ReflectIntersect

func ReflectIntersect(a, b any) any

ReflectIntersect uses reflection to compute the intersection of two slices

func ReflectIsSubsetOf

func ReflectIsSubsetOf(is, of any) bool

ReflectIsSubsetOf uses reflection to check if a slice is a subset of another

func ReflectIsSupersetOf

func ReflectIsSupersetOf(is, of any) bool

ReflectIsSupersetOf uses reflection to check if a slice is a superset of another

func ReflectSliceCast

func ReflectSliceCast(slice any, newType any) any

func ReflectSliceContains

func ReflectSliceContains(v any, slice any) bool

ReflectSliceContains checks if a slice contains a value using reflection

func ReflectUnion

func ReflectUnion(a, b any) any

ReflectUnion uses reflection to compute the union of two slices

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

func Slicify(in any) any

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

func StringsEqualIfSet(a, b string) bool

StringsEqualIfSet checks if two strings are equal if they are both not empty

Types

This section is empty.

Jump to

Keyboard shortcuts

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