Documentation ¶
Index ¶
- Constants
- type DeepCopier
- func (dc *DeepCopier) From(tagged interface{}) error
- func (dc *DeepCopier) GetTagOptions(value string) map[string]string
- func (dc *DeepCopier) HandleField(options *FieldOptions) error
- func (dc *DeepCopier) HandleMethod(options *FieldOptions) error
- func (dc *DeepCopier) HandleStructField(options *FieldOptions) error
- func (dc *DeepCopier) ProcessCopy() error
- func (dc *DeepCopier) SetField(options *FieldOptions) error
- func (dc *DeepCopier) SetFieldValue(entity interface{}, name string, value reflect.Value) error
- func (dc *DeepCopier) To(tagged interface{}) error
- func (dc *DeepCopier) WithContext(context map[string]interface{}) *DeepCopier
- type FieldOptions
Constants ¶
const ( // TagName is struct field tag name. TagName = "deepcopier" // FieldOptionName is the from field option name for struct tag. FieldOptionName = "field" // ContextOptionName is the context option name for struct tag. ContextOptionName = "context" // SkipOptionName is the skip option name for struct tag. SkipOptionName = "skip" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeepCopier ¶
type DeepCopier struct { Source interface{} Destination interface{} Tagged interface{} Context map[string]interface{} Reversed bool }
DeepCopier deep copies a struct to/from a struct.
func (*DeepCopier) From ¶
func (dc *DeepCopier) From(tagged interface{}) error
From sets the given tagged struct as source and the current source as destination. Source <- Destination
func (*DeepCopier) GetTagOptions ¶
func (dc *DeepCopier) GetTagOptions(value string) map[string]string
GetTagOptions parses deepcopier tag field and returns options.
func (*DeepCopier) HandleField ¶
func (dc *DeepCopier) HandleField(options *FieldOptions) error
HandleField sets value for the given field.
func (*DeepCopier) HandleMethod ¶
func (dc *DeepCopier) HandleMethod(options *FieldOptions) error
HandleMethod tries to call method on model and sets result in resource field.
func (*DeepCopier) HandleStructField ¶
func (dc *DeepCopier) HandleStructField(options *FieldOptions) error
HandleStructField sets the value for the given supported struct field.
func (*DeepCopier) ProcessCopy ¶
func (dc *DeepCopier) ProcessCopy() error
ProcessCopy processes copy.
func (*DeepCopier) SetField ¶
func (dc *DeepCopier) SetField(options *FieldOptions) error
SetField sets the value of the given field.
func (*DeepCopier) SetFieldValue ¶
func (dc *DeepCopier) SetFieldValue(entity interface{}, name string, value reflect.Value) error
SetFieldValue Sets the given value to the given field.
func (*DeepCopier) To ¶
func (dc *DeepCopier) To(tagged interface{}) error
To sets the given tagged struct as destination struct. Source -> Destination
func (*DeepCopier) WithContext ¶
func (dc *DeepCopier) WithContext(context map[string]interface{}) *DeepCopier
WithContext injects the given context into the builder instance.