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

Function IgnoreFields

cmp/cmpopts/ignore.go:24–27  ·  view source on GitHub ↗

IgnoreFields returns an [cmp.Option] that ignores fields of the given names on a single struct type. It respects the names of exported fields that are forwarded due to struct embedding. The struct type is specified by passing in a value of that type. The name may be a dot-delimited string (e.g., "F

(typ interface{}, names ...string)

Source from the content-addressed store, hash-verified

22// The name may be a dot-delimited string (e.g., "Foo.Bar") to ignore a
23// specific sub-field that is embedded or nested within the parent struct.
24func IgnoreFields(typ interface{}, names ...string) cmp.Option {
25 sf := newStructFilter(typ, names...)
26 return cmp.FilterPath(sf.filter, cmp.Ignore())
27}
28
29// IgnoreTypes returns an [cmp.Option] that ignores all values assignable to
30// certain types, which are specified by passing in a value of each type.

Callers 2

TestOptionsFunction · 0.85

Calls 3

FilterPathFunction · 0.92
IgnoreFunction · 0.92
newStructFilterFunction · 0.85

Tested by 2

TestOptionsFunction · 0.68