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

Function AllowUnexported

cmp/options.go:430–440  ·  cmp/options.go::AllowUnexported

AllowUnexported returns an [Option] that allows [Equal] to forcibly introspect unexported fields of the specified struct types. See [Exporter] for the proper use of this option.

(types ...interface{})

Source from the content-addressed store, hash-verified

428//
429// See [Exporter] for the proper use of this option.
430func AllowUnexported(types ...interface{}) Option {
431 m := make(map[reflect.Type]bool)
432 for _, typ := range types {
433 t := reflect.TypeOf(typ)
434 if t.Kind() != reflect.Struct {
435 panic(fmt.Sprintf("invalid struct type: %T", typ))
436 }
437 m[t] = true
438 }
439 return exporter(func(t reflect.Type) bool { return m[t] })
440}
441
442// Result represents the comparison result for a single node and
443// is provided by cmp when calling Report (see [Reporter]).

Callers 5

comparerTestsFunction · 0.92
embeddedTestsFunction · 0.92
project3TestsFunction · 0.92
project4TestsFunction · 0.92
TestOptionsFunction · 0.92

Calls 1

exporterFuncType · 0.85

Tested by 5

comparerTestsFunction · 0.74
embeddedTestsFunction · 0.74
project3TestsFunction · 0.74
project4TestsFunction · 0.74
TestOptionsFunction · 0.74