-
Notifications
You must be signed in to change notification settings - Fork 222
Open
Description
version: go-cmp@v0.7.0, go@v1.21.3
When I was comparing slices of maps defined as:
a := []any{map[string]any{"a": 1, "b": 2, "c": 3}}
b := []any{map[string]any{"a": 2, "b": 4, "c": 3}}
fmt.Println(cmp.Diff(a,b))The result is:
[]any{
map[string]any{
- "a": int(1)
- "a": int(2)
- "b": int(2)
- "b": int(4)
"c": int(3)
},
}
Which means it traversed inside the map entries.
However, when I was doing this:
a := []any{map[string]any{"a": 1, "b": 2, "c": 3}}
b := []any{map[string]any{"a": 2, "b": 4, "c": 6}}
fmt.Println(cmp.Diff(a,b))The result become:
[]any{
- map[string]any{"a": int(1), "b": int(2), "c": int(3)},
+ map[string]any{"a": int(2), "b": int(4), "c": int(6)},
}
I've tested several tests, and it seems that it stops traversing only when the map have three or more differences. Is it a bug, or am I doing anything wrong? Since I'm using go-cmp to handle deserialized objects, this case will affect the path filter.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels