mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
show type differences in reflect diff
This commit is contained in:
parent
67e7d4c68f
commit
6354665ee8
@ -108,6 +108,14 @@ func limit(aObj, bObj interface{}, max int) (string, string) {
|
||||
elidedASuffix := ""
|
||||
elidedBSuffix := ""
|
||||
a, b := fmt.Sprintf("%#v", aObj), fmt.Sprintf("%#v", bObj)
|
||||
|
||||
if aObj != nil && bObj != nil {
|
||||
if aType, bType := fmt.Sprintf("%T", aObj), fmt.Sprintf("%T", bObj); aType != bType {
|
||||
a = fmt.Sprintf("%s (%s)", a, aType)
|
||||
b = fmt.Sprintf("%s (%s)", b, bType)
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
switch {
|
||||
case len(a) > max && len(a) > 4 && len(b) > 4 && a[:4] == b[:4]:
|
||||
|
@ -75,6 +75,11 @@ object.A:
|
||||
a: []int(nil)
|
||||
b: []int{}`,
|
||||
},
|
||||
"display type differences": {a: []interface{}{int64(1)}, b: []interface{}{uint64(1)}, out: `
|
||||
object[0]:
|
||||
a: 1 (int64)
|
||||
b: 0x1 (uint64)`,
|
||||
},
|
||||
}
|
||||
for name, test := range testCases {
|
||||
expect := test.out
|
||||
|
Loading…
Reference in New Issue
Block a user