I've been using reflect.DeepEqual
to deeply compare structs using circular pointers. As that does not work with maps and for better test output, I've switched to go-cmp
.
Now I had to take note that even though cmp.Equal
is supposed to be a drop-in replacement for reflect.DeepEqual
, in cases where the former works correctly, there's a different result in this case, even though it actually is deeply equal.
Can anyone tell me why the result is different in this case and ideally, how to fix it?
Code in Go playground: https://play.golang.com/p/rLWKwMlAfwu
(Updated to use fmt.Printf(), because I couldn't get testing
running in playground)
Output for diff:
StrongConnect() mismatch (-want +got):
&⟪ref#0⟫main.Edge{
StartNode: &⟪ref#1⟫main.Node{
Variable: 1,
- Low: &⟪ref#0: 0xc00005c120⟫(...),
+ Low: &⟪ref#0: 0xc00005c120⟫(...),
High: &{StartNode: &⟪ref#1⟫(...), EndNode: &{Variable: 2}, EdgeType: 1, Weight: 1},
},
EndNode: &{Variable: 2},
EdgeType: 0,
Weight: 1,
}