I have a test that compares the equality of two pointers to instances of a struct (MyStruct). The pointers are stored within other structs (container1 and container2). Here's how I check the equality:
require.Equal(*container1.MyStruct, *container2.MyStruct)
the Equals() method is from the Testify library: https://github.com/stretchr/testify/blob/master/require/require_forward.go#L128
This test passes when I run it on my Mac. However, when I push my changes to our build server (Linux), the test fails. The error message is the standard Error: Not equal... message, but when I diff the expected and actual shown in the output, they're exactly the same!
I thought maybe Go is somehow comparing the addresses of the pointers rather than the contents, but the comment on require.Equal makes this seem unlikely:
// Pointer variable equality is determined based on the equality of the referenced values (as opposed to the memory addresses)
Any idea what's going on here? Does Go behave differently on Mac vs Linux?
I'm not able to post specifics here as it's an issue I'm seeing in a codebase I touch at work.
require.Equalandassert.Equalare usingreflect.DeepEqualin their implementation as I remember. The only problem is when you try to compare struct which contains maps because they do not keep order. But it should work otherwise.