Handle more cases in diff.ObjectReflectDiff

Interfaces and nested map values were not being recursed.
This commit is contained in:
Clayton Coleman
2016-07-04 15:04:38 -04:00
parent cd7a56ba46
commit b765203a91

View File

@@ -145,7 +145,7 @@ func objectReflectDiff(path *field.Path, a, b reflect.Value) []diff {
}
}
return changes
case reflect.Ptr:
case reflect.Ptr, reflect.Interface:
if a.IsNil() || b.IsNil() {
switch {
case a.IsNil() && b.IsNil():
@@ -199,7 +199,7 @@ func objectReflectDiff(path *field.Path, a, b reflect.Value) []diff {
if reflect.DeepEqual(a.MapIndex(key).Interface(), b.MapIndex(key).Interface()) {
continue
}
missing = append(missing, diff{path: path.Key(fmt.Sprintf("%s", key.Interface())), a: a.MapIndex(key).Interface(), b: b.MapIndex(key).Interface()})
missing = append(missing, objectReflectDiff(path.Key(fmt.Sprintf("%s", key.Interface())), a.MapIndex(key), b.MapIndex(key))...)
continue
}
missing = append(missing, diff{path: path.Key(fmt.Sprintf("%s", key.Interface())), a: nil, b: b.MapIndex(key).Interface()})