Skip to content

Commit

Permalink
Merge pull request #54 from hjr265/patch-1
Browse files Browse the repository at this point in the history
Apply same filters when producing struct values
  • Loading branch information
purehyperbole authored Apr 19, 2021
2 parents 9e5baa4 + 2060e5a commit 4e4ce4b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions diff_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (d *Differ) diffStruct(path []string, a, b reflect.Value) error {

func (d *Differ) structValues(t string, path []string, a reflect.Value) error {
var nd Differ
nd.Filter = d.Filter

if t != CREATE && t != DELETE {
return ErrInvalidChangeType
Expand Down Expand Up @@ -98,6 +99,10 @@ func (d *Differ) structValues(t string, path []string, a reflect.Value) error {

fpath := copyAppend(path, tname)

if nd.Filter != nil && !nd.Filter(fpath, a.Type(), field) {
continue
}

err := nd.diff(fpath, xf, af, a.Interface())
if err != nil {
return err
Expand Down

0 comments on commit 4e4ce4b

Please sign in to comment.