Documentation
¶
Index ¶
Constants ¶
const (
DefaultTagName = "copy"
)
Variables ¶
var ( // ErrTypeInvalid returned when type of input var does not meet the requirement ErrTypeInvalid = errors.New("ErrTypeInvalid") // ErrTypeNonCopyable returned when the function can not perform copying between types ErrTypeNonCopyable = errors.New("ErrTypeNonCopyable") // ErrValueInvalid returned when input value does not meet the requirement ErrValueInvalid = errors.New("ErrValueInvalid") // ErrValueUnaddressable returned when value is `unaddressable` which is required // in some situations such as when accessing an unexported struct field. ErrValueUnaddressable = errors.New("ErrValueUnaddressable") // ErrFieldRequireCopying returned when a field is required to be copied // but no copying is done for it. ErrFieldRequireCopying = errors.New("ErrFieldRequireCopying") // ErrMethodInvalid returned when copying method of a struct is not valid ErrMethodInvalid = errors.New("ErrMethodInvalid") )
Errors may be returned from Copy function
Functions ¶
func Copy ¶
Copy performs deep copy from `src` to `dst`.
`dst` must be a pointer to the output var, `src` can be either value or pointer. In case you want to copy unexported struct fields within `src`, `src` must be a pointer.
func SetDefaultTagName ¶ added in v1.1.0
func SetDefaultTagName(tag string)
SetDefaultTagName overwrites the default tag name. This function should only be called once at program startup.
Types ¶
type Context ¶
type Context struct { // CopyBetweenPtrAndValue allow or not copying between pointers and values (default is `true`) CopyBetweenPtrAndValue bool // CopyBetweenStructFieldAndMethod allow or not copying between struct fields and methods (default is `true`) CopyBetweenStructFieldAndMethod bool // IgnoreNonCopyableTypes ignore non-copyable types (default is `false`) IgnoreNonCopyableTypes bool // UseGlobalCache if false not use global cache (default is `true`) UseGlobalCache bool // contains filtered or unexported fields }
Context copier context
type Option ¶
type Option func(ctx *Context)
Option configuration option function provided as extra arguments of copying function
func CopyBetweenPtrAndValue ¶
CopyBetweenPtrAndValue config function for setting flag `CopyBetweenPtrAndValue`
func CopyBetweenStructFieldAndMethod ¶
CopyBetweenStructFieldAndMethod config function for setting flag `CopyBetweenStructFieldAndMethod`
func IgnoreNonCopyableTypes ¶
IgnoreNonCopyableTypes config function for setting flag `IgnoreNonCopyableTypes`
func UseGlobalCache ¶
UseGlobalCache config function for setting flag `UseGlobalCache`