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

Add cmpopts.EquateComparable #340

Merged
merged 1 commit into from Aug 31, 2023
Merged

Add cmpopts.EquateComparable #340

merged 1 commit into from Aug 31, 2023

Commits on Aug 31, 2023

  1. Add cmpopts.EquateComparable

    This helper function makes it easier to specify that comparable types
    are safe to directly compare with the == operator in Go.
    
    The API does not use generics as it follows existing options like
    cmp.AllowUnexported, cmpopts.IgnoreUnexported, or cmpopts.IgnoreTypes.
    
    While generics provides type safety, the user experience is not as nice.
    Our current API allows multiple types to be specified:
    	cmpopts.EquateComparable(netip.Addr{}, netip.Prefix{})
    While generics would not allow variadic arguments:
    	cmpopts.EquateComparable[netip.Addr]()
    	cmpopts.EquateComparable[netip.Prefix]()
    
    Bump mininimum supported Go to 1.18 for net/netip type.
    Start testing on Go 1.21.
    
    Fixes #339
    dsnet committed Aug 31, 2023
    Configuration menu
    Copy the full SHA
    9c6fd5b View commit details
    Browse the repository at this point in the history