Skip to content

helper function to always show field used by SortSlices to determine equality is omitted from diff #382

@khumps

Description

@khumps

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions