@@ -54,7 +54,8 @@ type Converter struct {
54
54
generatedConversionFuncs ConversionFuncs
55
55
56
56
// Set of conversions that should be treated as a no-op
57
- ignoredConversions map [typePair ]struct {}
57
+ ignoredConversions map [typePair ]struct {}
58
+ ignoredUntypedConversions map [typePair ]struct {}
58
59
59
60
// This is a map from a source field type and name, to a list of destination
60
61
// field type and name.
@@ -83,12 +84,13 @@ type Converter struct {
83
84
// NewConverter creates a new Converter object.
84
85
func NewConverter (nameFn NameFunc ) * Converter {
85
86
c := & Converter {
86
- conversionFuncs : NewConversionFuncs (),
87
- generatedConversionFuncs : NewConversionFuncs (),
88
- ignoredConversions : make (map [typePair ]struct {}),
89
- nameFunc : nameFn ,
90
- structFieldDests : make (map [typeNamePair ][]typeNamePair ),
91
- structFieldSources : make (map [typeNamePair ][]typeNamePair ),
87
+ conversionFuncs : NewConversionFuncs (),
88
+ generatedConversionFuncs : NewConversionFuncs (),
89
+ ignoredConversions : make (map [typePair ]struct {}),
90
+ ignoredUntypedConversions : make (map [typePair ]struct {}),
91
+ nameFunc : nameFn ,
92
+ structFieldDests : make (map [typeNamePair ][]typeNamePair ),
93
+ structFieldSources : make (map [typeNamePair ][]typeNamePair ),
92
94
93
95
inputFieldMappingFuncs : make (map [reflect.Type ]FieldMappingFunc ),
94
96
inputDefaultFlags : make (map [reflect.Type ]FieldMatchingFlags ),
@@ -377,6 +379,7 @@ func (c *Converter) RegisterIgnoredConversion(from, to interface{}) error {
377
379
return fmt .Errorf ("expected pointer arg for 'to' param 1, got: %v" , typeTo )
378
380
}
379
381
c .ignoredConversions [typePair {typeFrom .Elem (), typeTo .Elem ()}] = struct {}{}
382
+ c .ignoredUntypedConversions [typePair {typeFrom , typeTo }] = struct {}{}
380
383
return nil
381
384
}
382
385
@@ -459,6 +462,11 @@ func (c *Converter) doConversion(src, dest interface{}, flags FieldMatchingFlags
459
462
flags : flags ,
460
463
meta : meta ,
461
464
}
465
+
466
+ // ignore conversions of this type
467
+ if _ , ok := c .ignoredUntypedConversions [pair ]; ok {
468
+ return nil
469
+ }
462
470
if fn , ok := c .conversionFuncs .untyped [pair ]; ok {
463
471
return fn (src , dest , scope )
464
472
}
0 commit comments