Documentation ¶
Overview ¶
Package zreflect provides reflection tools
package main import ( "github.com/sohaha/zlsgo/zreflect" ) type Demo struct { Name string } func main() { typ := zreflect.TypeOf(Demo{}) println(typ.NumMethod()) }
Index ¶
- Constants
- Variables
- func CanExpand(t reflect.Type) bool
- func CanInline(t reflect.Type) bool
- func ForEach(typ reflect.Type, ...) (err error)
- func ForEachMethod(valof reflect.Value, ...) error
- func ForEachValue(val reflect.Value, ...) (err error)
- func GetAbbrKind(val reflect.Value) reflect.Kind
- func GetStructTag(field reflect.StructField, tags ...string) (tagValue, tagOpts string)
- func GetUnexportedField(v reflect.Value, field string) (interface{}, error)
- func IsLabel(t reflect.Type) bool
- func Nonzero(v reflect.Value) bool
- func SetUnexportedField(v reflect.Value, field string, value interface{}) error
- func TypeOf(v interface{}) reflect.Type
- func ValueOf(v interface{}) reflect.Value
- type Type
- type Value
Constants ¶
View Source
const (
Tag = "z"
)
Variables ¶
View Source
var ( // SkipChild Field is returned when a struct field is skipped. SkipChild = errors.New("skip struct") )
Functions ¶
func ForEach ¶ added in v1.6.4
func ForEach(typ reflect.Type, fn func(parent []string, index int, tag string, field reflect.StructField) error) (err error)
ForEach For Each Struct field
func ForEachMethod ¶ added in v1.6.4
func ForEachValue ¶ added in v1.6.4
func ForEachValue(val reflect.Value, fn func(parent []string, index int, tag string, field reflect.StructField, val reflect.Value) error) (err error)
ForEachValue For Each Struct field and value
func GetStructTag ¶
func GetStructTag(field reflect.StructField, tags ...string) (tagValue, tagOpts string)
func GetUnexportedField ¶ added in v1.6.4
GetUnexportedField Get unexported field, hazardous operation, please use with caution
func SetUnexportedField ¶ added in v1.6.4
SetUnexportedField Set unexported field, hazardous operation, please use with caution
Types ¶
Click to show internal directories.
Click to hide internal directories.