Skip to content

Commit 1496ea2

Browse files
committed
fix
1 parent 85a127b commit 1496ea2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

algo/algorithm.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,14 @@ func IsNil(v any) bool {
155155
if v == nil {
156156
return true
157157
}
158-
return reflect.ValueOf(v).IsNil()
158+
159+
var value = reflect.ValueOf(v)
160+
switch value.Kind() {
161+
case reflect.Chan, reflect.Func, reflect.Map, reflect.Pointer, reflect.Slice, reflect.Interface:
162+
return value.IsNil()
163+
default:
164+
return v == nil
165+
}
159166
}
160167

161168
// NotNil 判断不为空

0 commit comments

Comments
 (0)