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.
21 lines
329 B
21 lines
329 B
package utils
|
|
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
// IsNil function evaluates the interface value to nil
|
|
func IsNil(i interface{}) bool {
|
|
|
|
type iface struct {
|
|
_ unsafe.Pointer
|
|
ptr unsafe.Pointer
|
|
}
|
|
|
|
unpacked := (*iface)(unsafe.Pointer(&i))
|
|
if unpacked.ptr == nil {
|
|
return true
|
|
}
|
|
|
|
return *(*unsafe.Pointer)(unpacked.ptr) == nil
|
|
}
|
|
|