Skip to content

Commit b630967

Browse files
committed
fix(diff): check edge case for nil interface (did panic)
Signed-off-by: Frederic BIDON <[email protected]>
1 parent 961f2aa commit b630967

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

internal/assertions/diff.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,16 @@ func diff(expected any, actual any) string {
6161

6262
func typeAndKind(v any) (reflect.Type, reflect.Kind) {
6363
t := reflect.TypeOf(v)
64-
k := t.Kind() // Proposal for enhancement: check if t is not nil
64+
if t == nil {
65+
return nil, reflect.Invalid
66+
}
67+
68+
k := t.Kind()
6569

6670
if k == reflect.Ptr {
6771
t = t.Elem()
6872
k = t.Kind()
6973
}
74+
7075
return t, k
7176
}

0 commit comments

Comments
 (0)