Skip to content

Commit

Permalink
fix example test and check if identifier call is for struct
Browse files Browse the repository at this point in the history
  • Loading branch information
purehyperbole committed Feb 10, 2022
1 parent c3c4714 commit db3f716
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ func tagName(tag string, f reflect.StructField) string {
}

func identifier(tag string, v reflect.Value) interface{} {
if v.Kind() != reflect.Struct {
return nil
}

for i := 0; i < v.NumField(); i++ {
if hasTagOption(tag, v.Type().Field(i), "identifier") {
return v.Field(i).Interface()
Expand Down
2 changes: 1 addition & 1 deletion diff_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func ExampleComplexSlicePatch() {

fmt.Printf("Patched %d entries and encountered %d errors", len(patchLog), patchLog.ErrorCount())

//Output: Patched 7 entries and encountered 4 errors
//Output: Patched 7 entries and encountered 3 errors
}

//ExampleComplexMapPatch demonstrates how to use the Patch function for complex slices.
Expand Down

0 comments on commit db3f716

Please sign in to comment.