Documentation ¶
Index ¶
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 must be non-nil and addressable") ErrInvalidCopyFrom = errors.New("copy from must be non-nil and addressable") 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") )
Functions ¶
func CopyWithOption ¶
CopyWithOption copy with option
Types ¶
type FieldNameMapping ¶
type Option ¶
type Option struct { Converters []TypeConverter // Custom field name mappings to copy values with different names in `fromValue` and `toValue` types. // Examples can be found in `copier_field_name_mapping_test.go`. FieldNameMapping []FieldNameMapping // 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 CaseSensitive bool DeepCopy bool }
Option sets copy options
type TypeConverter ¶
type TypeConverter struct { SrcType interface{} DstType interface{} Fn func(src interface{}) (dst interface{}, err error) }
type Valuer ¶
type Valuer interface {
CopyValue() interface{}
}
Valuer lets custom types implement a function returning the actual value to copy. For example if your type is a wrapper, or if it doesn't have to implement `sql/driver.Valuer`, you can implement this interface so the returned value will be used instead. It can also be used to format your type or convert it to another one before being copied. This also enables conversion for types using generics, as you cannot use them with `TypeConverter`.
Click to show internal directories.
Click to hide internal directories.