Closed crawshaw closed 10 months ago
At present, cmp
has no special treatment of any type in the Go stdlib, including time.Time
, which instigated the invention of this package. I think this is a reasonable design goal as special treatment of any particular type begs the question of where to draw the line. Even if we limit cmp
to just the stdlib, that's a lot of types that would be linked in.
I see a few options:
netip.Addr
(and friends) implement an Equal
method.cmpopts.EquateComparable
helper that shallow compares the types passed to it (e.g., cmpopts.EquateComparable(netip.Addr{}, netip.Prefix{})
).cmp
stop panicking on unexported fields, and just compare fields recursively as it would otherwise.At minimum, we should probably do option 2 as it makes this easier.
Now that
netip
is in the stdlib, it would be nice if go-cmp supported it by default. Today you need to add:to make
cmp.Diff
work with types that include netip types.