github.com/sandwich-go/boost@v1.3.29/isnil/check.go (about) 1 package isnil 2 3 import "reflect" 4 5 type isNiler interface { 6 IsNil() bool 7 } 8 9 // Check checks if any is nil. 10 func Check(any interface{}) bool { 11 if any == nil { 12 return true 13 } 14 15 if checker, ok := any.(isNiler); ok { 16 return checker.IsNil() 17 } 18 19 v := reflect.ValueOf(any) 20 return v.Kind() == reflect.Ptr && v.IsNil() 21 }