reflectx

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllFieldName

func GetAllFieldName(m interface{}) ([]string, error)

func GetFieldByName

func GetFieldByName(m interface{}, n string) (reflect.StructField, error)

func GetFieldValueByName

func GetFieldValueByName(m interface{}, n string) reflect.Value

func GetType

func GetType(m interface{}) reflect.Type

func GetValueByName

func GetValueByName(m interface{}, n string) interface{}

func IsPoint

func IsPoint(m interface{}) bool

IsPoint 判断是否为指针

func IsPtr

func IsPtr[T any](v T) bool

IsPtr 判断当前是否为指针

func NilOrZero

func NilOrZero(m interface{}, fs string) bool

func PrintInterface

func PrintInterface(v interface{})

PrintInterface print the interface by level

func SafeStruct

func SafeStruct(v interface{}) interface{}

SafeStruct 必须传入指针 它会将空指针的字段设置为该类型的零值的指针 传入空指针会返回一个所有字段都为零值的结构体

func SafeValue

func SafeValue[T any](v T) T

SafeValue 可以传指针,也可以传值 传指针则返回指针,传值则返回值 遇到空指针会返回该类型的零值的指针

func SetFieldValue

func SetFieldValue(m interface{}, n string, v reflect.Value) error

func ToInterfaceSlice

func ToInterfaceSlice(src interface{}) []interface{}

将切片转成 []interface{}

Types

This section is empty.

Jump to

Keyboard shortcuts

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