reflectutil

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareValues

func CompareValues(a, b interface{}) int

CompareValues compares two values for sorting Returns -1 if a < b, 0 if a == b, 1 if a > b

func DeepEqual

func DeepEqual(a, b interface{}) bool

DeepEqual performs a deep equality check between two values

func Deref

func Deref(v reflect.Value) (reflect.Value, bool)

Deref dereferences pointers until it reaches a non-pointer value Returns the dereferenced value and true if successful, or the original value and false if nil

func DerefInterface

func DerefInterface(i interface{}) reflect.Value

DerefInterface dereferences an interface{} until it reaches a non-pointer value

func GetFieldValue

func GetFieldValue(item interface{}, field string) interface{}

GetFieldValue extracts a field value from a struct, map, or pointer Returns nil if the field doesn't exist or can't be accessed

func GetNestedValue

func GetNestedValue(m interface{}, path string) interface{}

GetNestedValue gets a nested value using dot notation path Example: GetNestedValue(obj, "database.schema.table")

func IsMap

func IsMap(i interface{}) bool

IsMap checks if an interface{} is a map

func IsSliceOrArray

func IsSliceOrArray(i interface{}) bool

IsSliceOrArray checks if an interface{} is a slice or array

func MapGet

func MapGet(m interface{}, key interface{}) interface{}

MapGet safely gets a value from a map by key Returns nil if key doesn't exist or not a map

func MapKeys

func MapKeys(i interface{}) []interface{}

MapKeys returns all keys from a map as []interface{} Returns empty slice if not a map

func MapLen

func MapLen(i interface{}) int

MapLen returns the length of a map, or 0 if not a map

func MapValues

func MapValues(i interface{}) []interface{}

MapValues returns all values from a map as []interface{} Returns empty slice if not a map

func SliceIndex

func SliceIndex(slice interface{}, index int) interface{}

SliceIndex safely gets an element from a slice/array by index Returns nil if index out of bounds or not a slice/array

func SliceLen

func SliceLen(i interface{}) int

SliceLen returns the length of a slice/array, or 0 if not a slice/array

func SliceToInterfaces

func SliceToInterfaces(i interface{}) []interface{}

SliceToInterfaces converts a slice/array to []interface{} Returns empty slice if not a slice/array

Types

This section is empty.

Jump to

Keyboard shortcuts

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