The PR provides the dcomparison.StructsDiff func which deeply compares two struct and returns dcomparison.ObjectDiffs with differences between both of them.
The path to each field is based on:
json field name if there is a json tag with json field name
the name of the field directly if there is no json field name
if there is a json inline constraint ,inline for an embedded struct it skips its name
The package also provides dcomparisonSkip struct tag which indicates if the struct field should be included in comparasing.
type SomeStruct struct {
// Field will be included in the result with json field name `field`
Field string `json:"field"`
// FieldToBeSkipped will not be included in comparasing
FieldToBeSkipped `json"fieldToBeSkipped" dcomprasionSkip"true"`
// unexportedField will not be included too
unexportedField `json"unexportedField"`
// In this case the name FieldWithJSONSkipConstraint will be included in the result
FieldWithJSONSkipConstraint `json"-"`
}
type StructWithEmbedded struct {
// the name of the ExportedStruct will not be included in the result.
// It means that the resulting path to the field inside
// embedded struct will be `StructWithEmbedded.field`
ExportedStruct `json:",inline"`
}
The PR provides the
dcomparison.StructsDiff
func which deeply compares two struct and returnsdcomparison.ObjectDiffs
with differences between both of them.The path to each field is based on:
,inline
for an embedded struct it skips its nameThe package also provides
dcomparisonSkip
struct tag which indicates if the struct field should be included in comparasing.