reflectutil

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstOfType

func FirstOfType[T any](values []reflect.Value) (T, bool)

FirstOfType returns the first value in the slice that matches the specified type. If no matching value is found, it returns the zero value of the type and false.

func GetConcreteElement

func GetConcreteElement(v reflect.Value) reflect.Value

GetConcreteElement returns the concrete reflect.Value of a reflect.Value when it is a pointer or interface or the same reflect.Value when it is already concrete.

func GetConcreteValue

func GetConcreteValue(v reflect.Value) any

GetConcreteValue returns the concrete value of a reflect.Value.

This function is used to get the concrete value of a reflect.Value even if it is a pointer or interface. Concrete values are values that are not pointers or interfaces (including maps, slices, structs, etc.).

func GetField

func GetField(v reflect.Value, fieldExpr string) (reflect.Value, error)

GetField returns the reflect.Value of a field in a struct or map.

func GetTypedField

func GetTypedField[T any](v reflect.Value, fieldExpr string) (T, bool)

func GetTypedValue

func GetTypedValue[T any](v any) (T, bool)

func IsNotConcrete

func IsNotConcrete(v reflect.Value) bool

IsNotConcrete returns true if the reflect.Value is a pointer or interface.

func LastOfType

func LastOfType[T any](values []reflect.Value) (T, bool)

func TracePath

func TracePath(v reflect.Value, fieldExpr string) ([]reflect.Value, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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