r3labs / diff

A library for diffing golang structures
Mozilla Public License 2.0
895 stars 84 forks source link

add filtering of struct fields #38

Closed alexflint closed 4 years ago

alexflint commented 4 years ago

This pr adds a new option Filter, which can be used like this

d, err := diff.NewDiffer(diff.Filter(func (path []string, parent reflect.Type, field reflect.StructField) bool {
  // return true to descend into the field, false to ignore it
}))

The parent argument will contain the type information for the struct being examined, and the field argument will contain the struct field being examined.

Closes #37

purehyperbole commented 4 years ago

Hi there, thanks for the contribution!

I will merge this now and cut a release.