reflector

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidInput means that the input is invalid
	ErrInvalidInput = errors.New("input is invalid")

	// ErrInvalidMethod means that the method is invalid
	ErrInvalidMethod = errors.New("method is invalid")

	// ErrInvalidFunc means that the func is invalid
	ErrInvalidFunc = errors.New("func is invalid")

	// ErrFieldCanNotBeSet means that the field can not be set
	ErrFieldCanNotBeSet = errors.New("field can not be set")
)

Functions

func CallFunc added in v0.4.0

func CallFunc(object interface{}, args ...interface{}) (interface{}, error)

CallFunc call function

func CallMethodByName

func CallMethodByName(object interface{}, name string, args ...interface{}) (interface{}, error)

CallMethodByName call method

func DeepFields

func DeepFields(reflectType reflect.Type) []reflect.StructField

DeepFields iterate struct field

func FindEmbeddedFieldTag added in v0.8.0

func FindEmbeddedFieldTag(object interface{}, name string) (t string, ok bool)

FindEmbeddedFieldTag find embedded field tag

func GetEmbeddedInterfaceField added in v0.5.0

func GetEmbeddedInterfaceField(object interface{}) (field reflect.StructField)

GetEmbeddedInterfaceField get embedded interface field

func GetEmbeddedInterfaceFieldByType added in v0.5.4

func GetEmbeddedInterfaceFieldByType(typ reflect.Type) (field reflect.StructField)

GetEmbeddedInterfaceFieldByType get embedded interface field by type

func GetFieldValue

func GetFieldValue(f interface{}, name string) reflect.Value

GetFieldValue get field value

func GetKind

func GetKind(kind reflect.Kind) reflect.Kind

GetKind get kind

func GetKindByType added in v0.5.0

func GetKindByType(typ reflect.Type) reflect.Kind

GetKindByType get kind by type

func GetKindByValue added in v0.5.0

func GetKindByValue(val reflect.Value) reflect.Kind

GetKindByValue get kind by value

func GetLowerCaseObjectName

func GetLowerCaseObjectName(data interface{}) (string, error)

GetLowerCaseObjectName get lower case object name

func GetName

func GetName(data interface{}) (name string, err error)

GetName get object name

func GetPkgPath added in v0.3.0

func GetPkgPath(object interface{}) string

GetPkgPath get the package patch

func GetType added in v0.5.0

func GetType(data interface{}) (typ reflect.Type, err error)

GetType get object data type

func HasEmbeddedField

func HasEmbeddedField(object interface{}, name string) bool

HasEmbeddedField check if has embedded fieled

func HasField

func HasField(object interface{}, name string) bool

HasField check if has specific field

func Indirect

func Indirect(reflectValue reflect.Value) reflect.Value

Indirect get indirect value

func IndirectType

func IndirectType(reflectType reflect.Type) reflect.Type

IndirectType get indirect type

func NewReflectType

func NewReflectType(st interface{}) interface{}

NewReflectType create instance by tyep

func ParseObjectName added in v0.3.0

func ParseObjectName(obj interface{}, eliminator string) string

ParseObjectName e.g. ExampleObject => example

func ParseObjectPkgName added in v0.4.0

func ParseObjectPkgName(obj interface{}) string

ParseObjectName e.g. ExampleObject => example

func SetFieldValue

func SetFieldValue(object interface{}, name string, value interface{}) error

SetFieldValue set field value

func Validate

func Validate(toValue interface{}) (*reflect.Value, error)

Validate validate value

func ValidateReflectType

func ValidateReflectType(obj interface{}, callback func(value *reflect.Value, reflectType reflect.Type, fieldSize int, isSlice bool) error) error

ValidateReflectType validate reflect type and iterate all fields

Types

This section is empty.

Jump to

Keyboard shortcuts

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