reflection

package
v1.20.9 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnyType added in v1.0.2

type AnyType string

type Reflection

type Reflection struct {
	IsPtr  bool
	IsZero bool
	IsTime bool // 是否是时间
	// contains filtered or unexported fields
}
var ReflectionApp Reflection

func New

func New(object any) *Reflection

New 实例化:反射帮助

func NewByReflectValue

func NewByReflectValue(refValue reflect.Value) *Reflection

NewByReflectValue 实例化:通过reflect.Value

func (*Reflection) CallMethodByName

func (my *Reflection) CallMethodByName(
	methodName string,
	values ...reflect.Value,
) []reflect.Value

CallMethodByName 通过名称调用方法

func (*Reflection) FindFieldAndFill

func (my *Reflection) FindFieldAndFill(
	target,
	tagTitle,
	tagField string,
	process func(val reflect.Value),
)

FindFieldAndFill 递归查找字段并填充

func (*Reflection) GetReflectionType

func (my *Reflection) GetReflectionType() ReflectionType

GetReflectionType 获取Reflection类型

func (*Reflection) GetType

func (my *Reflection) GetType() reflect.Type

GetType 获取reflect.Type

func (*Reflection) GetValue

func (my *Reflection) GetValue() reflect.Value

GetValue 获取reflect.Value

func (*Reflection) HasField added in v1.0.14

func (my *Reflection) HasField(fieldName string) bool

HasField 判断结构体是否有某个字段

func (*Reflection) IsSame

func (my *Reflection) IsSame(value any) bool

IsSame 判断两个类型是否相等

func (*Reflection) IsSameDeepEqual

func (my *Reflection) IsSameDeepEqual(value any) bool

IsSameDeepEqual 判断两个值是否相等

func (*Reflection) Iter added in v1.12.20

func (my *Reflection) Iter(fn func(k, v any)) (isIter bool)

Iter 迭代

func (*Reflection) New added in v1.9.10

func (*Reflection) New(object any) *Reflection

func (*Reflection) NewByValue added in v1.9.10

func (*Reflection) NewByValue(refValue reflect.Value) *Reflection

func (*Reflection) Serialize added in v1.18.8

func (my *Reflection) Serialize() []string

Serialize 序列化

type ReflectionType

type ReflectionType string
const (
	Int               ReflectionType = "I"
	Int8              ReflectionType = "I8"
	Int16             ReflectionType = "I16"
	Int32             ReflectionType = "I32"
	Int64             ReflectionType = "I64"
	Uint              ReflectionType = "U"
	Uint8             ReflectionType = "U8"
	Uint16            ReflectionType = "U16"
	Uint32            ReflectionType = "U32"
	Uint64            ReflectionType = "U64"
	String            ReflectionType = "STRING"
	Float32           ReflectionType = "F32"
	Float64           ReflectionType = "F64"
	Datetime          ReflectionType = "DATETIME"
	Bool              ReflectionType = "BOOL"
	Array             ReflectionType = "ARRAY"
	Map               ReflectionType = "MAP"
	Struct            ReflectionType = "STRUCT"
	Nil               ReflectionType = "NIL"
	PtrSliceAny       ReflectionType = "*[]ANY"
	PtrSlicePtrStruct ReflectionType = "*[]*STRUCT"
	PtrSliceStruct    ReflectionType = "*[]STRUCT"
	PtrSlicePtrMap    ReflectionType = "*[]*MAP"
	PtrSliceMap       ReflectionType = "*[]MAP"
	PtrStruct         ReflectionType = "*STRUCT"
	PtrPtrStruct      ReflectionType = "**STRUCT"
	PtrPtrMap         ReflectionType = "**MAP"
	PtrMap            ReflectionType = "*MAP" // 1
	Any               ReflectionType = "ANY"
	UnKnowType        ReflectionType = "UKT"
)

Jump to

Keyboard shortcuts

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