You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
356 B
23 lines
356 B
package utils
|
|
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
// IsNil function evaluates the interface value to nil
|
|
func IsNil(i interface{}) (isNil bool) {
|
|
|
|
type iface struct {
|
|
_ unsafe.Pointer
|
|
ptr unsafe.Pointer
|
|
}
|
|
|
|
unpacked := (*iface)(unsafe.Pointer(&i))
|
|
if unpacked.ptr == nil {
|
|
isNil = true
|
|
return
|
|
}
|
|
|
|
isNil = *(*unsafe.Pointer)(unpacked.ptr) == nil
|
|
return
|
|
}
|
|
|