dyn

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package dyn (dynamic) is an extension to the `reflect` package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddressOf

func AddressOf(x any) string

AddressOf returns the memory address of given item as string

func AnyValue

func AnyValue(value reflect.Value) (any, bool)

AnyValue returns an `any` object that holds the value of given reflect.Value, and flag if it is valid

func Deref

func Deref(x any) (any, bool)

Deref dereferences the given pointer, and returns flag if it is valid

func DerefValue

func DerefValue(x any) (reflect.Value, bool)

DerefValue dereferences the given pointer, and returns reflect.Value and flag if it is valid

func FullTypeName

func FullTypeName(x any) string

FullTypeName returns the full type name of given item (*Type for pointers)

func GetStructField

func GetStructField(structRef any, field string) (any, bool)

GetStructField gets item.field from given struct pointer, and returns flag for successful get

func GetStructFieldAs

func GetStructFieldAs[T any](structRef any, field string) (T, bool)

GetStructFieldAs gets item.field from given struct pointer, and type coerces it into T, and returns flag for successful get

func GetStructFieldAsString

func GetStructFieldAsString(structRef any, field string) (string, bool)

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 IsEqual

func IsEqual(x, y any) bool

IsEqual checks if the two `any` values are equal

func IsNil

func IsNil(x any) bool

IsNil checks if given item is nil

func IsPointer

func IsPointer(x any) bool

IsPointer checks if given item is a pointer

func IsStruct

func IsStruct(x any) bool

IsStruct checks if given item is a struct

func IsStructPointer

func IsStructPointer(x any) bool

IsStructPointer checks if given item is a pointer to a struct

func IsZero

func IsZero(x any) bool

IsZero checks if given item has zero value

func MustAnyValue

func MustAnyValue(value reflect.Value) any

MustAnyValue returns an `any` object that holds the value of given reflect.Value This panics if value is private.

func MustDeref

func MustDeref(x any) any

MustDeref dereferences the given pointer, panics if item is not a pointer

func MustDerefValue

func MustDerefValue(x any) reflect.Value

MustDerefValue dereferences the given pointer and returns reflect.Value This panics if item is not a pointer

func MustGetStructField

func MustGetStructField(structRef any, field string) any

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

func MustGetStructFieldAsString(structRef any, field string) string

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

func MustRefValue(value reflect.Value) any

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

func MustSetStructField(structRef any, field string, value any)

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 NotEqual

func NotEqual(x, y any) bool

NotEqual checks if the two `any` values are not equal

func NotNil

func NotNil(x any) bool

NotNil checks if given item is not nil

func RefValue

func RefValue(value reflect.Value) (any, bool)

RefValue returns an `any` object that holds a reference to given reflect.Value, and flag if it is valid

func SetStructField

func SetStructField(structRef any, field string, value any) bool

SetStructField sets item.field = value for the given struct pointer, returns flag for successful operation

func TypeName

func TypeName(x any) string

TypeName returns the base type name of given item (dereferences pointers)

Types

This section is empty.

Jump to

Keyboard shortcuts

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