Skip to content

Commit

Permalink
Apply same filters when producing struct values
Browse files Browse the repository at this point in the history
Closes #53
  • Loading branch information
hjr265 authored Apr 18, 2021
1 parent faaae30 commit 2060e5a
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 2060e5a

Please sign in to comment.