From 2060e5a1a5364e79f6acbc115e1b2b0027b3ce7d Mon Sep 17 00:00:00 2001 From: Mahmud Ridwan Date: Sun, 18 Apr 2021 16:14:01 +0600 Subject: [PATCH] Apply same filters when producing struct values Closes #53 --- diff_struct.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/diff_struct.go b/diff_struct.go index 57298b5..4e7045f 100644 --- a/diff_struct.go +++ b/diff_struct.go @@ -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 @@ -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