Provisioning: Add better nil check (#110847)
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package util
|
||||
|
||||
import "reflect"
|
||||
|
||||
func IsInterfaceNil(i interface{}) bool {
|
||||
iv := reflect.ValueOf(i)
|
||||
if !iv.IsValid() {
|
||||
return true
|
||||
}
|
||||
switch iv.Kind() {
|
||||
case reflect.Ptr, reflect.Slice, reflect.Map, reflect.Func, reflect.Interface:
|
||||
return iv.IsNil()
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user