utils

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: MIT Imports: 6 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 HashStruct added in v0.8.0

func HashStruct(v any) (string, error)

HashStruct hashes a struct using msgpack and SHA3-256.

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 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

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, newType any) any

ReflectSliceCast converts a slice to another type using reflection. Parameters:

  • slice: source slice to convert
  • newType: target type for the slice elements

Retur Returns:

  • converted slice or original value if input is not a slice

func ReflectSliceContains

func ReflectSliceContains(v, 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 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

Types

This section is empty.

Jump to

Keyboard shortcuts

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