Documentation ¶
Index ¶
- func Cast[T any](v any) (T, error)
- func CastType(t reflect.Type, v any) (reflect.Value, error)
- func GetIntefaceName[T any]() string
- func GetMethodByName(t reflect.Type, name string) (reflect.Method, bool)
- func GetPointerOfValue(val reflect.Value) any
- func GetReflectTypeName(t reflect.Type) string
- func NewStructInstance(t reflect.Type) (reflect.Value, error)
- func SameType[A any, B any]() bool
- func SetField(target reflect.Value, field reflect.StructField, value reflect.Value) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cast ¶
Cast casts a value to the provided type. Handles resolving pointers and interfaces. Returns the casted value and an error if the value cannot be casted T: The type to cast to v: The value to cast
func CastType ¶
CastType casts a value to the provided type. Handles resolving pointers and interfaces. Returns the casted value and an error if the value cannot be casted t: The type to cast to v: The value to cast
func GetIntefaceName ¶
GetIntefaceName returns the name of the interface in the format `modulePath.interfaceName` T: The type to get the name of
func GetMethodByName ¶
GetMethodByName gets a method by name. If the method is not found, it will check for a pointer to the type and return the method if found. Returns the method and a bool indicating if the method was found t: The type to get the method from name: The name of the method
func GetPointerOfValue ¶
GetPointerOfValue gets the pointer of a value. If the value is already a pointer, it will return the value. If the value is not addressable, it will return the value. Otherwise, it will return the address of the value val: The value to get the pointer of
func GetReflectTypeName ¶
GetReflectTypeName returns the name of the type in the format `modulePath.typeName` t: The type to get the name of
func NewStructInstance ¶
NewStructInstance creates a new instance of a struct. Throws an error if t is not a struct t: The type of the struct
func SameType ¶
SameType checks if the provided types are the same. Handles resolving interfaces. Returns true if the types are the same, false otherwise A: The first type to compare B: The second type to compare
Types ¶
This section is empty.