helper function to always show field used by SortSlices to determine equality is omitted from diff
- Dominant language
- Go
- Stars
- 4.7k
- Forks
- 243
- PR merge metrics
- No merged PRs in 30d
Description
I have a SortSlices func like
```
cmpopts.SortSlices(func(a, b zpe.SwitchInterface) int {
return strings.Compare(a.ID, b.ID)
})
```
I get back a diff like
```
SwitchInterfaces: []zpe.SwitchInterface(Inverse(cmpopts.SortSlices, []zpe.SwitchInterface{
{
... // 16 identical fields
PortDescription: "interface_description",
MstpBpduGuard: "off",
- UntaggedVLAN: "",
+ UntaggedVLAN: "1",
TaggedVLAN: "",
AutoNegotiation: "",
},
{
... // 16 identical fields
PortDescription: "interface_description",
MstpBpduGuard: "off",
- UntaggedVLAN: "",
+ UntaggedVLAN: "1",
TaggedVLAN: "",
AutoNegotiation: "",
},
```
unfortunately the ID is now hidden in identical fields, but it is critical to understanding the diff. It would be nice if there was some utility option to always show a field in a diff for a type.
I envision an interface similar to cmpopts.IgnoreFields() but it guarentees a diff always will show a field if a diff exists for objects that match that type.
Contributor guide
Assessment
This issue has not been assessed yet.