zreflect

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 5 Imported by: 6

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

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 CanExpand

func CanExpand(t reflect.Type) bool

func CanInline

func CanInline(t reflect.Type) bool

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 ForEachMethod(valof reflect.Value, fn func(index int, method reflect.Method, value reflect.Value) error) error

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 GetAbbrKind added in v1.6.4

func GetAbbrKind(val reflect.Value) reflect.Kind

func GetStructTag

func GetStructTag(field reflect.StructField, tags ...string) (tagValue, tagOpts string)

func GetUnexportedField added in v1.6.4

func GetUnexportedField(v reflect.Value, field string) (interface{}, error)

GetUnexportedField Get unexported field, hazardous operation, please use with caution

func IsLabel added in v1.6.4

func IsLabel(t reflect.Type) bool

func Nonzero

func Nonzero(v reflect.Value) bool

func SetUnexportedField added in v1.6.4

func SetUnexportedField(v reflect.Value, field string, value interface{}) error

SetUnexportedField Set unexported field, hazardous operation, please use with caution

func TypeOf

func TypeOf(v interface{}) reflect.Type

func ValueOf

func ValueOf(v interface{}) reflect.Value

Types

type Type added in v1.6.4

type Type = *rtype

func NewType added in v1.6.4

func NewType(v interface{}) Type

type Value added in v1.6.4

type Value struct {
	// contains filtered or unexported fields
}

func NewValue added in v1.6.4

func NewValue(v interface{}) Value

func (Value) Native added in v1.6.4

func (v Value) Native() reflect.Value

func (Value) Type added in v1.6.4

func (v Value) Type() Type

Jump to

Keyboard shortcuts

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