Documentation ¶
Index ¶
- Variables
- func CallID(obj interface{}) string
- 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 DefaultWhiteList() []string
- func FieldByIndexErr(v reflect.Value, index []int) (reflect.Value, error)
- func GetModifiableField(val reflect.Value, name string) (reflect.Value, bool)
- func GetModifiableFields(val reflect.Value, callback func(tagName, name string))
- 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 ParamDump(s interface{}, f io.Writer, seriesLength ...int)
- func ParseStructAndInject(f interface{}, objects ...interface{}) error
- func PrintConfig(s interface{}, f io.Writer, style *table.Style, withColor bool, ...)
- func Test_injectField(t *testing.T)
- func Test_parseStructAndInject(t *testing.T)
- func ToReflectValues(args ...interface{}) (values []reflect.Value)
- type InstanceIDProvider
- 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 DefaultWhiteList ¶
func DefaultWhiteList() []string
func FieldByIndexErr ¶
Modified from golang 1.19.1 reflect to eliminate all possible panic
func GetModifiableField ¶
func GetModifiableFields ¶
Used by bbgo/interact_modify.go
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 ParamDump ¶
@param s: strategy object @param f: io.Writer used for writing the strategy dump @param seriesLength: if exist, the first value will be chosen to be the length of data from series to be printed out
default to 1 when not exist or the value is invalid
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 PrintConfig ¶
func PrintConfig(s interface{}, f io.Writer, style *table.Style, withColor bool, whiteLists ...string)
@param s: strategy object @param f: io.Writer used for writing the config dump @param style: pretty print table style. Use NewDefaultTableStyle() to get default one. @param withColor: whether to print with color @param whiteLists: fields to be printed out from embedded struct (1st layer only)
func Test_injectField ¶
func ToReflectValues ¶
ToReflectValues convert the go objects into reflect.Value slice
Types ¶
type InstanceIDProvider ¶
type InstanceIDProvider interface {
InstanceID() string
}