MCPcopy
hub / github.com/google/go-cmp / FilterPath

Function FilterPath

cmp/options.go:118–126  ·  view source on GitHub ↗

FilterPath returns a new [Option] where opt is only evaluated if filter f returns true for the current [Path] in the value tree. This filter is called even if a slice element or map entry is missing and provides an opportunity to ignore such cases. The filter function must be symmetric such that th

(f func(Path) bool, opt Option)

Source from the content-addressed store, hash-verified

116// The option passed in may be an [Ignore], [Transformer], [Comparer], [Options], or
117// a previously filtered [Option].
118func FilterPath(f func(Path) bool, opt Option) Option {
119 if f == nil {
120 panic("invalid path filter function")
121 }
122 if opt := normalizeOption(opt); opt != nil {
123 return &pathFilter{fnc: f, opt: opt}
124 }
125 return nil
126}
127
128type pathFilter struct {
129 core

Callers 13

comparerTestsFunction · 0.92
transformerTestsFunction · 0.92
methodTestsFunction · 0.92
BenchmarkBytesFunction · 0.92
EquateComparableFunction · 0.92
IgnoreFieldsFunction · 0.92
IgnoreTypesFunction · 0.92
IgnoreInterfacesFunction · 0.92
IgnoreUnexportedFunction · 0.92
IgnoreSliceElementsFunction · 0.92
IgnoreMapEntriesFunction · 0.92
filterFieldFunction · 0.92

Calls 1

normalizeOptionFunction · 0.85

Tested by 4

comparerTestsFunction · 0.74
transformerTestsFunction · 0.74
methodTestsFunction · 0.74
BenchmarkBytesFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…