MCPcopy
hub / github.com/istio/istio / opts

Function opts

pkg/test/util/assert/assert.go:54–71  ·  view source on GitHub ↗

opts gets the comparison opts for a type. This includes some defaults, but allows each type to explicitly append their own.

(a T)

Source from the content-addressed store, hash-verified

52
53// opts gets the comparison opts for a type. This includes some defaults, but allows each type to explicitly append their own.
54func opts[T any](a T) []cmp.Option {
55 if o, ok := any(a).(cmpOptioner); ok {
56 opts := append([]cmp.Option{}, cmpOpts...)
57 opts = append(opts, o.CmpOpts()...)
58 return opts
59 }
60 // if T is actually a slice (ex: []A), check that and get the opts for the element type (A).
61 t := reflect.TypeOf(a)
62 if t != nil && t.Kind() == reflect.Slice {
63 v := reflect.New(t.Elem()).Elem().Interface()
64 if o, ok := v.(cmpOptioner); ok {
65 opts := append([]cmp.Option{}, cmpOpts...)
66 opts = append(opts, o.CmpOpts()...)
67 return opts
68 }
69 }
70 return cmpOpts
71}
72
73var cmpOpts = []cmp.Option{protocmp.Transform(), cmpopts.EquateEmpty(), compareErrors}
74

Callers 5

BenchmarkLogFunction · 0.85
CompareFunction · 0.85
EqualFunction · 0.85
EventuallyEqualFunction · 0.85
ConsistentlyFunction · 0.85

Calls 3

CmpOptsMethod · 0.65
KindMethod · 0.65
NewMethod · 0.65

Tested by 1

BenchmarkLogFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…