Documentation
¶
Overview ¶
Package dyn (dynamic) is an extension to the `reflect` package
Index ¶
- func AddressOf(x any) string
- func AnyValue(value reflect.Value) (any, bool)
- func Deref(x any) (any, bool)
- func DerefValue(x any) (reflect.Value, bool)
- func FullTypeName(x any) string
- func GetStructField(structRef any, field string) (any, bool)
- func GetStructFieldAs[T any](structRef any, field string) (T, bool)
- func GetStructFieldAsString(structRef any, field string) (string, bool)
- func GetStructFieldTag(structField reflect.StructField, tagKey string) (string, bool)
- func IsEqual(x, y any) bool
- func IsNil(x any) bool
- func IsPointer(x any) bool
- func IsStruct(x any) bool
- func IsStructPointer(x any) bool
- func IsZero(x any) bool
- func MustAnyValue(value reflect.Value) any
- func MustDeref(x any) any
- func MustDerefValue(x any) reflect.Value
- func MustGetStructField(structRef any, field string) any
- func MustGetStructFieldAsString(structRef any, field string) string
- func MustRefValue(value reflect.Value) any
- func MustSetStructField(structRef any, field string, value any)
- func NotEqual(x, y any) bool
- func NotNil(x any) bool
- func RefValue(value reflect.Value) (any, bool)
- func SetStructField(structRef any, field string, value any) bool
- func TypeName(x any) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnyValue ¶
AnyValue returns an `any` object that holds the value of given reflect.Value, and flag if it is valid
func DerefValue ¶
DerefValue dereferences the given pointer, and returns reflect.Value and flag if it is valid
func FullTypeName ¶
FullTypeName returns the full type name of given item (*Type for pointers)
func GetStructField ¶
GetStructField gets item.field from given struct pointer, and returns flag for successful get
func GetStructFieldAs ¶
GetStructFieldAs gets item.field from given struct pointer, and type coerces it into T, and returns flag for successful get
func GetStructFieldAsString ¶
GetStructFieldAsString gets item.field from given struct pointer, and return field value as string
func GetStructFieldTag ¶
func GetStructFieldTag(structField reflect.StructField, tagKey string) (string, bool)
GetStructFieldTag extracts the tag value from the struct field
func IsStructPointer ¶
IsStructPointer checks if given item is a pointer to a struct
func MustAnyValue ¶
MustAnyValue returns an `any` object that holds the value of given reflect.Value This panics if value is private.
func MustDerefValue ¶
MustDerefValue dereferences the given pointer and returns reflect.Value This panics if item is not a pointer
func MustGetStructField ¶
MustGetStructField gets item.field from given struct pointer. It returns nil if the given item is not a struct pointer. This panics if the given field is not accessible (not found or private)
func MustGetStructFieldAsString ¶
MustGetStructFieldAsString gets item.field from given struct pointer, and returns field value as string It returns "<nil>" if the given item is not a struct pointer. This panics if the given field is not accessible (not found or private).
func MustRefValue ¶
MustRefValue returns an `any` object that holds a reference to given reflect.Value This panics if value is not addressable or if it is private
func MustSetStructField ¶
MustSetStructField sets item.field = value for the given struct pointer. If the given item is not a struct pointer, this is a no-op. This panics if the given value cannot be assigned to the struct field (wrong value type or field does not exist)
func RefValue ¶
RefValue returns an `any` object that holds a reference to given reflect.Value, and flag if it is valid
func SetStructField ¶
SetStructField sets item.field = value for the given struct pointer, returns flag for successful operation
Types ¶
This section is empty.