Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
lxzan committed Feb 23, 2024
2 parents 5873fab + 1496ea2 commit 678f529
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion algo/algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,14 @@ func IsNil(v any) bool {
if v == nil {
return true
}
return reflect.ValueOf(v).IsNil()

var value = reflect.ValueOf(v)
switch value.Kind() {
case reflect.Chan, reflect.Func, reflect.Map, reflect.Pointer, reflect.Slice, reflect.Interface:
return value.IsNil()
default:
return v == nil
}
}

// NotNil 判断不为空
Expand Down

0 comments on commit 678f529

Please sign in to comment.