@@ -116,16 +116,18 @@ func diffValues(path *pathNode, v1, v2 reflect.Value, changes *[]Change) {
116
116
}
117
117
case reflect .Map :
118
118
if v1Type .Key ().Kind () == reflect .String {
119
- diffMap (path , v1 , v2 , changes )
119
+ diffMapStringKey (path , v1 , v2 , changes )
120
120
} else {
121
- if ! reflect .DeepEqual (v1 .Interface (), v2 .Interface ()) {
122
- * changes = append (* changes , Change {Field : path .String (), Old : v1 .Interface (), New : v2 .Interface ()})
123
- }
124
- }
125
- default : // primitives, interfaces, etc.
126
- if ! reflect .DeepEqual (v1 .Interface (), v2 .Interface ()) {
127
- * changes = append (* changes , Change {Field : path .String (), Old : v1 .Interface (), New : v2 .Interface ()})
121
+ deepEqualValues (path , v1 , v2 , changes )
128
122
}
123
+ default :
124
+ deepEqualValues (path , v1 , v2 , changes )
125
+ }
126
+ }
127
+
128
+ func deepEqualValues (path * pathNode , v1 , v2 reflect.Value , changes * []Change ) {
129
+ if ! reflect .DeepEqual (v1 .Interface (), v2 .Interface ()) {
130
+ * changes = append (* changes , Change {Field : path .String (), Old : v1 .Interface (), New : v2 .Interface ()})
129
131
}
130
132
}
131
133
@@ -173,14 +175,15 @@ func diffStruct(path *pathNode, s1, s2 reflect.Value, changes *[]Change) {
173
175
}
174
176
}
175
177
176
- func diffMap (path * pathNode , m1 , m2 reflect.Value , changes * []Change ) {
178
+ func diffMapStringKey (path * pathNode , m1 , m2 reflect.Value , changes * []Change ) {
177
179
keySet := map [string ]reflect.Value {}
178
180
for _ , k := range m1 .MapKeys () {
179
- ks := fmt .Sprint (k .Interface ())
181
+ // Key is always string at this point
182
+ ks := k .Interface ().(string )
180
183
keySet [ks ] = k
181
184
}
182
185
for _ , k := range m2 .MapKeys () {
183
- ks := fmt . Sprint ( k .Interface ())
186
+ ks := k .Interface ().( string )
184
187
keySet [ks ] = k
185
188
}
186
189
0 commit comments