cmpopts EquateApproxTime doesn't handle time.Time as map keys
nahojer opened this issue · 2 comments
nahojer commented
It seems that cmpopts.EquateApproxTime
doesn't handle the case when the type is of e.g. map[time.Time]string
. But maybe this is by design?
dsnet commented
Hi, this is working as intended, the documentation says:
Maps are equal if they are both nil or both non-nil, where recursively calling Equal on all non-ignored map entries report equal. Map keys are equal according to the == operator. To use custom comparisons for map keys, consider using cmpopts.SortMaps. Empty non-nil maps and nil maps are not equal; to equate empty maps, consider using cmpopts.EquateEmpty.
It provides alternative solutions such as using cmpopts.SortMaps
.
nahojer commented
Thanks for clarifying! Closing this issue.