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{})
| 428 | // |
| 429 | // See [Exporter] for the proper use of this option. |
| 430 | func 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]). |