reflectx

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForEachField

func ForEachField(o interface{}, excludePrivateField bool, f FieldAcceptor) error

func ForEachFieldV2

func ForEachFieldV2(t reflect.Type, v reflect.Value, excludePrivateField bool, f FieldAcceptor) error

func Id added in v1.2.0

func Id(c any) string

func Interfaces2Values

func Interfaces2Values(o []any) []reflect.Value

func IsImplement

func IsImplement(instance any, _interface any) bool

func IsTypeImplement

func IsTypeImplement(typ reflect.Type, _interface any) bool

func New added in v1.1.0

func New(t reflect.Type) reflect.Value

func Set added in v1.1.0

func Set(dst, src reflect.Value)

func TryCallMethod

func TryCallMethod(b interface{}, methodName string, args ...any) []reflect.Value

func TypeId added in v1.2.0

func TypeId(p reflect.Type) string

func Values2Interfaces

func Values2Interfaces(values []reflect.Value) []any

func WalkField

func WalkField(o interface{}, f FieldWalkAcceptor) error

WalkField walk the struct field with DFS, and break when meeting the nil pointer value, can be checked by value.Elem().InValid()

func WalkFieldV2

func WalkFieldV2(t reflect.Type, v reflect.Value, f FieldWalkAcceptor) error

Types

type FieldAcceptor

type FieldAcceptor func(field reflect.StructField, value reflect.Value) error

type FieldWalkAcceptor added in v1.2.0

type FieldWalkAcceptor func(parent *Node, field reflect.StructField, value reflect.Value) error

type Node added in v1.2.0

type Node struct {
	Parent *Node
	Field  reflect.StructField
	Value  reflect.Value
}

func (*Node) Path added in v1.2.0

func (n *Node) Path() []*Node

Jump to

Keyboard shortcuts

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