Documentation ¶
Index ¶
- Variables
- func CallMatch(f interface{}, objects ...interface{}) ([]reflect.Value, error)
- func CallStructFieldsMethod(m interface{}, method string, args ...interface{}) error
- func CanInt(v reflect.Value) bool
- func HasField(rs reflect.Value, fieldName string) (field reflect.Value, ok bool)
- func InheritStructValues(dst, src interface{})
- func InjectField(rs reflect.Value, fieldName string, obj interface{}, pointerOnly bool) error
- func IterateFields(obj interface{}, cb func(ft reflect.StructField, fv reflect.Value) error) error
- func IterateFieldsByTag(obj interface{}, tagName string, cb StructFieldIterator) error
- func LookupSymbolField(rs reflect.Value) (string, bool)
- func NewTypeValueInterface(typ reflect.Type) interface{}
- func ParseStructAndInject(f interface{}, objects ...interface{}) error
- func Test_injectField(t *testing.T)
- func Test_parseStructAndInject(t *testing.T)
- func ToReflectValues(args ...interface{}) (values []reflect.Value)
- type StructFieldIterator
Constants ¶
This section is empty.
Variables ¶
var ErrCanNotIterateNilPointer = errors.New("can not iterate struct on a nil pointer")
Functions ¶
func CallMatch ¶
CallMatch calls the function with the matched argument automatically you can define multiple parameter factory function to inject the return value as the function argument. e.g.,
CallMatch(targetFunction, 1, 10, true, func() *ParamType { .... })
func CallStructFieldsMethod ¶
CallStructFieldsMethod iterates field from the given struct object check if the field object implements the interface, if it's implemented, then we call a specific method
func InheritStructValues ¶
func InheritStructValues(dst, src interface{})
InheritStructValues merges the field value from the source struct to the dest struct. Only fields with the same type and the same name will be updated.
func InjectField ¶
func IterateFields ¶
func IterateFieldsByTag ¶
func IterateFieldsByTag(obj interface{}, tagName string, cb StructFieldIterator) error
func ParseStructAndInject ¶
func ParseStructAndInject(f interface{}, objects ...interface{}) error
ParseStructAndInject parses the struct fields and injects the objects into the corresponding fields by its type. if the given object is a reference of an object, the type of the target field MUST BE a pointer field. if the given object is a struct value, the type of the target field CAN BE a pointer field or a struct value field.
func Test_injectField ¶
func ToReflectValues ¶
ToReflectValues convert the go objects into reflect.Value slice