Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmpopts EquateApproxTime doesn't handle time.Time as map keys #333

Closed
nahojer opened this issue Jul 8, 2023 · 2 comments
Closed

cmpopts EquateApproxTime doesn't handle time.Time as map keys #333

nahojer opened this issue Jul 8, 2023 · 2 comments

Comments

@nahojer
Copy link

nahojer commented Jul 8, 2023

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?

@nahojer nahojer closed this as completed Jul 8, 2023
@nahojer nahojer reopened this Jul 8, 2023
@dsnet
Copy link
Collaborator

dsnet commented Jul 8, 2023

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
Copy link
Author

nahojer commented Jul 9, 2023

Thanks for clarifying! Closing this issue.

@nahojer nahojer closed this as completed Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants