返回 DeepSeek-Reasonix
nil.go
根目录 / internal / nilutil / nil.go
1 package nilutil
2
3 import "reflect"
4
5 // IsNil reports whether v is nil or an interface holding a typed nil value.
6 func IsNil(v any) bool {
7 if v == nil {
8 return true
9 }
10 rv := reflect.ValueOf(v)
11 switch rv.Kind() {
12 case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Pointer, reflect.Slice:
13 return rv.IsNil()
14 default:
15 return false
16 }
17 }
18
18 lines GO