chore: use derive for eq checks #3521
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This patch adds https://github.com/awalterschulze/goderive for generating equality checks. I would want to have this approach instead of manually writing the equality checks as they are less error prone.
In theory it can also be used to generate the clone methods, however there's a bug with time handling, so that is not something I would do right now: awalterschulze/goderive#91.
Right now we cannot use reflect.deepequals for equality checks as for example alpacadecimal when in fallback mode (e.g. uses the shopspring decimal) uses an exponential representation of the number, for example
8*2^2
(==32). However the library does not normalize the exponent, so it can be also represented as32*2^0
. These values are not deepequal, however the type's Equal member returns the good value.