Documentation
¶
Index ¶
- Constants
- Variables
- func Copy(fromObj, toObj interface{}, opts ...Opt) (result interface{})
- func DeepCopy(fromObj, toObj interface{}, opts ...Opt) (result interface{})
- func DeepDiff(a, b typ.Any, opts ...diff.Opt) (delta diff.Diff, equal bool)
- func DeepEqual(a, b typ.Any, opts ...diff.Opt) (equal bool)
- func FallbackToBuiltinStringMarshalling(source reflect.Value) (str string, err error)
- func MakeClone(fromObj interface{}) (result interface{})
- func RegisterDefaultConverters(ss ...ValueConverter)
- func RegisterDefaultCopiers(ss ...ValueCopier)
- func RegisterDefaultStringMarshaller(m TextMarshaller)
- func ResetDefaultCopyController()
- func TimestampFromFloat64(ts float64) time.Time
- type BoolSlice
- type Cloneable
- type ComplexSlice
- type Complexes
- type Cvt
- func (s *Cvt) Bool(data any) bool
- func (s *Cvt) BoolMap(data any) map[string]bool
- func (s *Cvt) BoolSlice(data any) []bool
- func (s *Cvt) Complex128(data any) complex128
- func (s *Cvt) Complex128Map(data any) map[string]complex128
- func (s *Cvt) Complex128Slice(data any) []complex128
- func (s *Cvt) Complex64(data any) complex64
- func (s *Cvt) Complex64Map(data any) map[string]complex64
- func (s *Cvt) Complex64Slice(data any) []complex64
- func (s *Cvt) Duration(data any) time.Duration
- func (s *Cvt) DurationMap(data any) map[string]time.Duration
- func (s *Cvt) DurationSlice(data any) []time.Duration
- func (s *Cvt) Float32(data any) float32
- func (s *Cvt) Float32Map(data any) map[string]float32
- func (s *Cvt) Float32Slice(data any) []float32
- func (s *Cvt) Float64(data any) float64
- func (s *Cvt) Float64Map(data any) map[string]float64
- func (s *Cvt) Float64Slice(data any) []float64
- func (s *Cvt) Int(data any) int64
- func (s *Cvt) Int16Map(data any) map[string]int16
- func (s *Cvt) Int16Slice(data any) []int16
- func (s *Cvt) Int32Map(data any) map[string]int32
- func (s *Cvt) Int32Slice(data any) []int32
- func (s *Cvt) Int64Map(data any) map[string]int64
- func (s *Cvt) Int64Slice(data any) []int64
- func (s *Cvt) Int8Map(data any) map[string]int8
- func (s *Cvt) Int8Slice(data any) []int8
- func (s *Cvt) IntMap(data any) map[string]int
- func (s *Cvt) IntSlice(data any) []int
- func (s *Cvt) String(data any) string
- func (s *Cvt) StringMap(data any) map[string]string
- func (s *Cvt) StringSlice(data any) []string
- func (s *Cvt) Time(data any) time.Time
- func (s *Cvt) TimeMap(data any) map[string]time.Time
- func (s *Cvt) TimeSlice(data any) []time.Time
- func (s *Cvt) Uint(data any) uint64
- func (s *Cvt) Uint16Map(data any) map[string]uint16
- func (s *Cvt) Uint16Slice(data any) []uint16
- func (s *Cvt) Uint32Map(data any) map[string]uint32
- func (s *Cvt) Uint32Slice(data any) []uint32
- func (s *Cvt) Uint64Map(data any) map[string]uint64
- func (s *Cvt) Uint64Slice(data any) []uint64
- func (s *Cvt) Uint8Map(data any) map[string]uint8
- func (s *Cvt) Uint8Slice(data any) []uint8
- func (s *Cvt) UintMap(data any) map[string]uint
- func (s *Cvt) UintSlice(data any) []uint
- type CvtV
- type DeepCopier
- type DeepCopyable
- type FloatSlice
- type Floats
- type IntSlice
- type Integers
- type NameConverter
- type NameConverterContext
- type NameConverters
- type Numerics
- type Opt
- func WithAutoExpandForInnerStruct(autoExpand bool) Opt
- func WithAutoNewForStructField(autoNew bool) Opt
- func WithCleanStrategies(flagsList ...cms.CopyMergeStrategy) Opt
- func WithCloneStyle() Opt
- func WithCopyFunctionResultToTarget(b bool) Opt
- func WithCopyStyle() Opt
- func WithCopyUnexportedField(b bool) Opt
- func WithIgnoreNames(names ...string) Opt
- func WithIgnoreNamesReset() Opt
- func WithPassSourceToTargetFunction(b bool) Opt
- func WithSourceValueExtractor(e SourceValueExtractor) Opt
- func WithStrategies(flagsList ...cms.CopyMergeStrategy) Opt
- func WithStrategiesReset(flagsList ...cms.CopyMergeStrategy) Opt
- func WithStringMarshaller(m TextMarshaller) Opt
- func WithStructTagName(name string) Opt
- func WithSyncAdvancing(syncAdvancing bool) Opt
- func WithTargetValueSetter(e TargetValueSetter) Opt
- func WithTryApplyConverterAtFirst(b bool) Opt
- func WithValueConverters(cvt ...ValueConverter) Opt
- func WithValueCopiers(cvt ...ValueCopier) Opt
- func WithWipeTargetSliceFirst(wipe bool) Opt
- func WithoutPanic() Opt
- type Params
- type Slice
- type SourceValueExtractor
- type StringSlice
- type Stringer
- type TargetValueSetter
- type TextMarshaller
- type ToString
- type UintSlice
- type Uintegers
- type ValueConverter
- type ValueConverterContext
- func (ctx *ValueConverterContext) IsCopyFunctionResultToTarget() bool
- func (ctx *ValueConverterContext) IsPassSourceToTargetFunction() bool
- func (ctx *ValueConverterContext) Preprocess(source reflect.Value, targetType reflect.Type, cvtOuter ValueConverter) (processed bool, target reflect.Value, err error)
- type ValueConverters
- type ValueCopier
- type ValueCopiers
Constants ¶
const (
// Version string for hedzr/evendeep package
Version = "1.3.13"
)
Variables ¶
var ( // ErrUnknownState error. ErrUnknownState = errors.New("unknown state, cannot copy to") // ErrCannotSet error. ErrCannotSet = errors.New("cannot set: %v (%v) -> %v (%v)") // ErrCannotCopy error. ErrCannotCopy = errors.New("cannot copy: %v (%v) -> %v (%v)") // ErrCannotConvertTo error. ErrCannotConvertTo = errors.New("cannot convert/set: %v (%v) -> %v (%v)") // ErrShouldFallback tells the caller please continue its // internal process. // The error would be used in your callback function. For // instance, you could return it in a target-setter (see // also WithTargetValueSetter()) to ask the Copier do a // standard processing, typically that will set the field // with reflection. ErrShouldFallback = errors.New("fallback to evendeep internals") )
var ( // DefaultCopyController provides standard deepcopy feature. // copy and merge slice or map to an existed target. DefaultCopyController *cpController // by newDeepCopier() )
var WithAutoExpandStructOpt = WithAutoExpandForInnerStruct(true) //nolint:gochecknoglobals //i know that
WithAutoExpandStructOpt is synonym of WithAutoExpandForInnerStruct(true).
var WithAutoNewForStructFieldOpt = WithAutoNewForStructField(true) //nolint:gochecknoglobals //i know that
WithAutoNewForStructFieldOpt is synonym of WithAutoNewForStructField(true).
var WithByNameStrategyOpt = WithCleanStrategies(cms.ByName) //nolint:gochecknoglobals //i know that
WithByNameStrategyOpt is synonym of cms.ByName by calling WithCleanStrategies.
If you're using WithByNameStrategyOpt and WithStrategies(...) at same time, please notes it will clear any existent flags before setting.
var WithByOrdinalStrategyOpt = WithCleanStrategies(cms.ByOrdinal) //nolint:gochecknoglobals //i know that
WithByOrdinalStrategyOpt is synonym of cms.ByOrdinal by calling WithCleanStrategies.
If you're using WithByOrdinalStrategyOpt and WithStrategies(...) at same time, please notes it will clear any existent flags before setting.
var WithCopyFunctionResultToTargetOpt = WithCopyFunctionResultToTarget(true) //nolint:gochecknoglobals //i know that
WithCopyFunctionResultToTargetOpt is shortcut of WithCopyFunctionResultToTarget.
var WithCopyStrategyOpt = WithCleanStrategies(cms.SliceCopy, cms.MapCopy) //nolint:gochecknoglobals //i know that
WithCopyStrategyOpt is synonym of cms.SliceCopy + cms.MapCopy by calling WithCleanStrategies.
If you're using WithCopyStrategyOpt and WithStrategies(...) at same time, please notes it will clear any existent flags before setting.
var WithCopyUnexportedFieldOpt = WithCopyUnexportedField(true) //nolint:gochecknoglobals //i know that
WithCopyUnexportedFieldOpt is shortcut of WithCopyUnexportedField.
var WithMergeStrategyOpt = WithCleanStrategies(cms.SliceMerge, cms.MapMerge) //nolint:gochecknoglobals //i know that
WithMergeStrategyOpt is synonym of cms.SliceMerge + cms.MapMerge by calling WithCleanStrategies.
If you're using WithMergeStrategyOpt and WithStrategies(...) at same time, please notes it will clear any existent flags before setting.
var WithORMDiffOpt = WithCleanStrategies(cms.ClearIfEq, cms.KeepIfNotEq, cms.ClearIfInvalid) //nolint:gochecknoglobals,lll //i know that
WithORMDiffOpt is synonym of cms.ClearIfEq + cms.KeepIfNotEq + cms.ClearIfInvalid by calling WithCleanStrategies.
If you're using WithORMDiffOpt and WithStrategies(...) at same time, please notes it will clear any existent flags before setting.
var WithOmitEmptyOpt = WithCleanStrategies(cms.OmitIfEmpty) //nolint:gochecknoglobals //i know that
WithOmitEmptyOpt is synonym of cms.OmitIfEmpty by calling Clean.
If you're using WithOmitEmptyOpt and WithStrategies(...) at same time, please notes it will clear any existent flags before setting.
var WithPassSourceToTargetFunctionOpt = WithPassSourceToTargetFunction(true) //nolint:gochecknoglobals //i know that
WithPassSourceToTargetFunctionOpt is shortcut of WithPassSourceToTargetFunction.
var WithSyncAdvancingOpt = WithSyncAdvancing(true) //nolint:gochecknoglobals //i know that
WithSyncAdvancingOpt is synonym of WithAutoExpandForInnerStruct(true).
var WithTryApplyConverterAtFirstOpt = WithTryApplyConverterAtFirst(true) //nolint:gochecknoglobals //i know that
WithTryApplyConverterAtFirstOpt is shortcut of WithTryApplyConverterAtFirst(true).
var WithWipeTargetSliceFirstOpt = WithWipeTargetSliceFirst(true) //nolint:gochecknoglobals //i know that
WithWipeTargetSliceFirstOpt is synonym of WithWipeTargetSliceFirst(true).
Functions ¶
func Copy ¶
func Copy(fromObj, toObj interface{}, opts ...Opt) (result interface{})
Copy is a synonym of DeepCopy.
DeepCopy makes a deep clone of a source object or merges it into the target.
func DeepCopy ¶
func DeepCopy(fromObj, toObj interface{}, opts ...Opt) (result interface{})
DeepCopy makes a deep clone of a source object or merges it into the target.
func DeepDiff ¶
DeepDiff compares a and b deeply inside.
delta, equal := evendeep.DeepDiff(a, b) fmt.Println(delta) fmt.Println(delta.PrettyPrint())
func DeepEqual ¶
DeepEqual compares a and b deeply inside.
equal := evendeep.DeepEqual(a, b) fmt.Println(equal)
func FallbackToBuiltinStringMarshalling ¶
FallbackToBuiltinStringMarshalling exposes the builtin string marshaling mechanism for your customized ValueConverter or ValueCopier.
func MakeClone ¶
func MakeClone(fromObj interface{}) (result interface{})
MakeClone makes a deep clone of a source object.
func RegisterDefaultConverters ¶
func RegisterDefaultConverters(ss ...ValueConverter)
RegisterDefaultConverters registers the ValueConverter list into default converters registry.
It takes effects on DefaultCopyController, MakeClone, DeepCopy, and New, ....
func RegisterDefaultCopiers ¶
func RegisterDefaultCopiers(ss ...ValueCopier)
RegisterDefaultCopiers registers the ValueCopier list into default copiers registry.
It takes effects on DefaultCopyController, MakeClone, DeepCopy, and New, ....
func RegisterDefaultStringMarshaller ¶
func RegisterDefaultStringMarshaller(m TextMarshaller)
RegisterDefaultStringMarshaller provides a string marshaller which will be applied when a map is going to be copied to string.
Default is json marshaller (json.MarshalIndent).
If encoding.TextMarshaler/json.Marshaler have been implemented, the source.MarshalText/MarshalJSON() will be applied.
It's synonym of WithStringMarshaller.
func ResetDefaultCopyController ¶
func ResetDefaultCopyController()
ResetDefaultCopyController discards the changes for DefaultCopyController and more.
func TimestampFromFloat64 ¶ added in v1.1.1
TimestampFromFloat64 returns a Timestamp equal to the given float64, assuming it too is an unix timestamp.
The float64 is interpreted as number of seconds, with everything after the decimal indicating milliseconds, microseconds, and nanoseconds
Types ¶
type Cloneable ¶
type Cloneable interface { // Clone return a pointer to copy of source object. // But you can return the copy itself with your will. Clone() any //nolint:revive }
Cloneable interface represents a cloneable object that supports Clone() method.
The native Clone algorithm of a Cloneable object can be adapted into DeepCopier.
type ComplexSlice ¶ added in v1.0.0
type ComplexSlice[T Complexes] []T
type Complexes ¶ added in v1.0.0
type Complexes interface { complex64 | complex128 }
type Cvt ¶ added in v1.0.0
type Cvt struct{}
func (*Cvt) Complex128 ¶ added in v1.0.0
func (s *Cvt) Complex128(data any) complex128
func (*Cvt) Complex128Map ¶ added in v1.0.0
func (s *Cvt) Complex128Map(data any) map[string]complex128
func (*Cvt) Complex128Slice ¶ added in v1.0.0
func (s *Cvt) Complex128Slice(data any) []complex128
func (*Cvt) Complex64Map ¶ added in v1.0.0
func (*Cvt) Complex64Slice ¶ added in v1.0.0
func (*Cvt) DurationMap ¶ added in v1.0.0
func (*Cvt) Float32Slice ¶ added in v1.0.0
func (*Cvt) Float64Slice ¶ added in v1.0.0
func (*Cvt) Int16Slice ¶ added in v1.0.0
func (*Cvt) Int32Slice ¶ added in v1.0.0
func (*Cvt) Int64Slice ¶ added in v1.0.0
func (*Cvt) StringSlice ¶ added in v1.0.0
func (*Cvt) Uint16Slice ¶ added in v1.0.0
func (*Cvt) Uint32Slice ¶ added in v1.0.0
func (*Cvt) Uint64Slice ¶ added in v1.0.0
func (*Cvt) Uint8Slice ¶ added in v1.0.0
type DeepCopier ¶
type DeepCopier interface { // CopyTo function. CopyTo(fromObj, toObj interface{}, opts ...Opt) (err error) //nolint:revive }
DeepCopier interface.
func New ¶
func New(opts ...Opt) DeepCopier
New gets a new instance of DeepCopier (the underlying is *cpController) different with DefaultCopyController.
Use New:
src, tgt := 123, 0 err = evendeep.New().CopyTo(src, &tgt)
Use package functions (With-opts might cumulate):
evendeep.Copy(src, &tgt) // or synonym: evendeep.DeepCopy(src, &tgt) tgt = evendeep.MakeClone(src)
Use DefaultCopyController (With-opts might cumulate):
evendeep.DefaultCopyController.CopyTo(src, &tgt)
The most conventional way is:
err := evendeep.New().CopyTo(src, &tgt)
func NewFlatDeepCopier ¶
func NewFlatDeepCopier(opts ...Opt) DeepCopier
NewFlatDeepCopier gets a new instance of DeepCopier (the underlying is *cpController) like NewDeepCopier but no merge strategies (SliceMerge and MapMerge).
type DeepCopyable ¶
type DeepCopyable interface {
DeepCopy() any //nolint:revive
}
DeepCopyable interface represents a cloneable object that supports DeepCopy() method.
The native DeepCopy algorithm of a DeepCopyable object can be adapted into DeepCopier.
type FloatSlice ¶ added in v1.0.0
type FloatSlice[T Floats] []T
type NameConverter ¶
type NameConverter interface { ToGoName(ctx *NameConverterContext, fieldName string) (goName string) ToFieldName(ctx *NameConverterContext, goName string) (fieldName string) }
NameConverter for internal used.
type NameConverterContext ¶
type NameConverterContext struct {
*Params
}
NameConverterContext for internal used.
type Opt ¶
type Opt func(c *cpController)
Opt options functor.
func WithAutoExpandForInnerStruct ¶
WithAutoExpandForInnerStruct does copy fields with flat struct. When autoExpandForInnerStruct is enabled, the iterator will go into any embedded struct and traverse its fields with a flatten mode.
For instance, the iteration on struct:
type A struct { F1 string F2 int } type B struct { F1 bool F2 A F3 float32 }
will produce the sequences:
B.F1, B.F2, B.F2 - A.F1, B.F2 - A.F2, B.F3
Default is true.
func WithAutoNewForStructField ¶
WithAutoNewForStructField does create new instance on ptr field of a struct.
When cloning to a new target object, it might be helpful.
Default is true.
func WithCleanStrategies ¶ added in v0.2.51
func WithCleanStrategies(flagsList ...cms.CopyMergeStrategy) Opt
WithCleanStrategies set the given flags into *cpController, older flags will be clear at first.
func WithCloneStyle ¶
func WithCloneStyle() Opt
WithCloneStyle sets the cpController to clone mode. In this mode, source object will be cloned to a new object and returned as new target object.
func WithCopyFunctionResultToTarget ¶
WithCopyFunctionResultToTarget invoke source function member and pass the result to the responsible target field.
It just works when target field is acceptable.
Default is true.
func WithCopyStyle ¶
func WithCopyStyle() Opt
WithCopyStyle sets the cpController to copier mode. In this mode, source object will be deepcopied to target object.
func WithCopyUnexportedField ¶
WithCopyUnexportedField try to copy the unexported fields with special way.
This feature needs unsafe package present.
Default is true.
func WithIgnoreNames ¶
WithIgnoreNames does specify the ignored field names list.
Use the filename wildcard match characters (aka. '*' and '?', and '**') as your advantages, the algor is isWildMatch() and dir.IsWildMatch.
These patterns will only be tested on struct fields.
func WithIgnoreNamesReset ¶
func WithIgnoreNamesReset() Opt
WithIgnoreNamesReset clear the ignored name list set.
func WithPassSourceToTargetFunction ¶
WithPassSourceToTargetFunction invoke target function member and pass the source as its input parameters.
Default is true.
func WithSourceValueExtractor ¶
func WithSourceValueExtractor(e SourceValueExtractor) Opt
WithSourceValueExtractor specify a source field value extractor, which will be applied on each field being copied to target.
Just work for non-nested struct.
For instance:
c := context.WithValue(context.TODO(), "Data", map[string]typ.Any{ "A": 12, }) tgt := struct { A int }{} evendeep.DeepCopy(c, &tgt, evendeep.WithSourceValueExtractor(func(targetName string) typ.Any { if m, ok := c.Value("Data").(map[string]typ.Any); ok { return m[targetName] } return nil })) if tgt.A != 12 { t.FailNow() }
func WithStrategies ¶
func WithStrategies(flagsList ...cms.CopyMergeStrategy) Opt
WithStrategies appends more flags into *cpController.
For example:
WithStrategies(cms.OmitIfZero, cms.OmitIfNil, cms.OmitIfEmpty, cms.NoOmit) WithStrategies(cms.ClearIfMissed, cms.ClearIfInvalid) WithStrategies(cms.KeepIfNotEq, cms.ClearIfEq)
func WithStrategiesReset ¶
func WithStrategiesReset(flagsList ...cms.CopyMergeStrategy) Opt
WithStrategiesReset clears the exists flags in a *cpController. So that you can append new ones (with WithStrategies(flags...)).
In generally, WithStrategiesReset is synonym of cms.SliceCopy + cms.MapCopy, since all strategies are cleared. A nothing Flags means that a set of default strategies will be applied, in other words, its include:
cms.Default, cms.NoOmit, cms.NoOmitTarget, cms.SliceCopy, cms.MapCopy, cms.ByOrdinal,
If a flagsList supplied, WithStrategiesReset will add them and set the state to false.
func WithStringMarshaller ¶
func WithStringMarshaller(m TextMarshaller) Opt
WithStringMarshaller provides a string marshaller which will be applied when a map is going to be copied to string.
Default is json marshaller.
If BinaryMarshaler has been implemented, the source.Marshal() will be applied.
It's synonym of RegisterDefaultStringMarshaller.
func WithStructTagName ¶
WithStructTagName set the name which is used for retrieve the struct tag pieces.
Default is "copy", the corresponding struct with tag looks like:
type AFT struct { flags flags.Flags `copy:",cleareq"` converter *ValueConverter wouldbe int `copy:",must,keepneq,omitzero,mapmerge"` ignored1 int `copy:"-"` ignored2 int `copy:",-"` }
func WithSyncAdvancing ¶
WithSyncAdvancing decides how to advance to next field especially a source field had been ignored. By default, (false), the target field won't be advanced while the source field had been ignored. For sync-advanced flag is true, the target field step to next.
Just for cms.ByOrdinal mode.
func WithTargetValueSetter ¶
func WithTargetValueSetter(e TargetValueSetter) Opt
WithTargetValueSetter _
In the TargetValueSetter you could return evendeep.ErrShouldFallback to call the evendeep standard processing.
TargetValueSetter can work for struct and map.
NOTE that the sourceNames[0] is current field name, and the whole sourceNames slice includes the path of the nested struct(s), in reversal order.
For instance:
type srcS struct { A int B bool C string } src := &srcS{ A: 5, B: true, C: helloString, } tgt := map[string]typ.Any{ "Z": "str", } err := evendeep.New().CopyTo(src, &tgt, evendeep.WithTargetValueSetter( func(value *reflect.Value, sourceNames ...string) (err error) { if value != nil { name := "Mo" + strings.Join(sourceNames, ".") tgt[name] = value.Interface() } return // ErrShouldFallback to call the evendeep standard processing }), ) if err != nil || tgt["MoA"] != 5 || tgt["MoB"] != true || tgt["MoC"] != helloString || tgt["Z"] != "str" { t.Errorf("err: %v, tgt: %v", err, tgt) t.FailNow() }
func WithTryApplyConverterAtFirst ¶
WithTryApplyConverterAtFirst specifies which is first when trying/applying ValueConverters and ValueCopiers.
func WithValueConverters ¶
func WithValueConverters(cvt ...ValueConverter) Opt
WithValueConverters gives a set of ValueConverter. The value converters will be applied on its Match returns ok.
func WithValueCopiers ¶
func WithValueCopiers(cvt ...ValueCopier) Opt
WithValueCopiers gives a set of ValueCopier. The value copiers will be applied on its Match returns ok.
func WithWipeTargetSliceFirst ¶ added in v0.2.51
WithWipeTargetSliceFirst enables the option which assumes the target Slice or Map will be wipe out at first before copying/merging from source field.
func WithoutPanic ¶
func WithoutPanic() Opt
WithoutPanic disable panic() call internally.
Default is true.
type Params ¶
type Params struct {
// contains filtered or unexported fields
}
Params is params package.
type SourceValueExtractor ¶
SourceValueExtractor provides a hook for handling the extraction from source field.
SourceValueExtractor can work for non-nested struct.
type StringSlice ¶ added in v1.0.0
type StringSlice[T string] []T
type TargetValueSetter ¶
TargetValueSetter provide a hook for handling the setup to a target field.
In the TargetValueSetter you could return evendeep.ErrShouldFallback to call the evendeep standard processing.
TargetValueSetter can work for struct and map.
NOTE that the sourceNames[0] is current field name, and the whole sourceNames slice includes the path of the nested struct(s), in reversal order.
type TextMarshaller ¶
TextMarshaller for string marshaling.
type ValueConverter ¶
type ValueConverter interface { Transform(ctx *ValueConverterContext, source reflect.Value, targetType reflect.Type) (target reflect.Value, err error) Match(params *Params, source, target reflect.Type) (ctx *ValueConverterContext, yes bool) }
ValueConverter for internal used.
type ValueConverterContext ¶
type ValueConverterContext struct {
*Params
}
ValueConverterContext for internal used.
func (*ValueConverterContext) IsCopyFunctionResultToTarget ¶
func (ctx *ValueConverterContext) IsCopyFunctionResultToTarget() bool
IsCopyFunctionResultToTarget does SAFELY test if copyFunctionResultToTarget is true or not.
func (*ValueConverterContext) IsPassSourceToTargetFunction ¶
func (ctx *ValueConverterContext) IsPassSourceToTargetFunction() bool
IsPassSourceToTargetFunction does SAFELY test if passSourceAsFunctionInArgs is true or not.
func (*ValueConverterContext) Preprocess ¶
func (ctx *ValueConverterContext) Preprocess(source reflect.Value, targetType reflect.Type, cvtOuter ValueConverter) (processed bool, target reflect.Value, err error)
Preprocess find out a converter to transform source to target. If no comfortable converter found, the return processed is false.
type ValueCopier ¶
type ValueCopier interface { CopyTo(ctx *ValueConverterContext, source, target reflect.Value) (err error) Match(params *Params, source, target reflect.Type) (ctx *ValueConverterContext, yes bool) }
ValueCopier for internal used.