reflectx

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2025 License: MIT Imports: 7 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidValue = reflect.Value{}
	InvalidType  = reflect.TypeOf(nil)
)

Functions

func AssertType added in v0.0.34

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

func CanCast added in v0.0.34

func CanCast[T any](v any) bool

func CanElem added in v0.0.24

func CanElem(k reflect.Kind) bool

func Clone added in v0.0.26

func Clone[T any](src T) (dst T)

func DeepCopy added in v0.0.26

func DeepCopy(v, x reflect.Value)

func Deref

func Deref(t reflect.Type) reflect.Type

Deref returns the basic type of t

func HackField added in v0.0.32

func HackField(v any, i int) reflect.Value

func HackFieldByName added in v0.0.32

func HackFieldByName(v any, name string) reflect.Value

func Indirect

func Indirect(v any) reflect.Value

Indirect deref all level pointer references

func IndirectNew

func IndirectNew(v any) reflect.Value

IndirectNew returns the indirect value of v this function is safe and WILL NOT trigger panic. if the input is invalid, InvalidValue returns. validation of return is recommended.

func IsBytes

func IsBytes(v any) bool

func IsFloat

func IsFloat(v any) bool

func IsInteger

func IsInteger(v any) bool

func IsNumeric

func IsNumeric(v any) bool

func IsZero

func IsZero(v any) bool

IsZero check if input v is zero

func MustAssertType added in v0.0.34

func MustAssertType[T any](v any) T

func New

func New(t reflect.Type) reflect.Value

New a `reflect.Value` with reflect.Type not like reflect.New, but new all level pointer ref

func NewElem

func NewElem(t reflect.Type) reflect.Value

NewElem new the indirect type of t

func ParseStructTag

func ParseStructTag(tag reflect.StructTag) map[string]string

ParseStructTag parse struct tag to tag key/value map eg: `tagKey:"tagName,tagFlag1,tagFlag2=v"` will parsed to map[string]string{"cmd": "tagName,tagFlag1,tagFlag2=v"}

func ParseTagValue added in v0.0.19

func ParseTagValue(tagValue string) (string, map[string]struct{})

ParseTagValue parse tag value to name and flags eg: "tagName,tagFlag1,tagFlag2=v" will be parsed to name: tagName, flags: map[string]{"tagFlag1", "tagFlag2=v"}

func Typename

func Typename(rt reflect.Type) string

Typename returns the full type name of rt

Types

This section is empty.

Jump to

Keyboard shortcuts

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