Documentation ¶
Index ¶
- Constants
- Variables
- func Copy(toValue interface{}, fromValue interface{}) (err error)
- func CopyWithOption(toValue interface{}, fromValue interface{}, opt Option) (err error)
- func DeepFindFields(reflectType reflect.Type, reflectValue reflect.Value, prefix string, ...) []reflect.StructField
- func InitNilFields(reflectType reflect.Type, reflectValue reflect.Value, prefix string, ...)
- type Option
- type TypeConverter
Constants ¶
View Source
const ( // Some default converter types for a nicer syntax String string = "" Bool bool = false Int int = 0 Float32 float32 = 0 Float64 float64 = 0 )
These flags define options for tag handling
Variables ¶
View Source
var ( ErrInvalidCopyDestination = errors.New("copy destination is invalid") ErrInvalidCopyFrom = errors.New("copy from is invalid") ErrMapKeyNotMatch = errors.New("map's key type doesn't match") ErrNotSupported = errors.New("not supported") ErrFieldNameTagStartNotUpperCase = errors.New("copier field name tag must be start upper case") )
View Source
var AllNilFields = map[string]struct{}{
`*`: {},
}
AllNilFields 初始化所有nil字段
Functions ¶
func CopyWithOption ¶
CopyWithOption copy with option
func DeepFindFields ¶
func DeepFindFields(reflectType reflect.Type, reflectValue reflect.Value, prefix string, needInitFields map[string]struct{}) []reflect.StructField
DeepFindFields deep finds all fields
Types ¶
type Option ¶
type Option struct { // setting this value to true will ignore copying zero values of all the fields, including bools, as well as a // struct having all it's fields set to their zero values respectively (see IsZero() in reflect/value.go) IgnoreEmpty bool DeepCopy bool Converters []TypeConverter }
Option sets copy options
type TypeConverter ¶ added in v0.0.3
type TypeConverter struct { SrcType interface{} DstType interface{} Fn func(src interface{}) (dst interface{}, err error) }
Click to show internal directories.
Click to hide internal directories.