summaryrefslogtreecommitdiff
path: root/internal/util/ptr.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/util/ptr.go')
-rw-r--r--internal/util/ptr.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/internal/util/ptr.go b/internal/util/ptr.go
index 8a89666c4..d0e835c9e 100644
--- a/internal/util/ptr.go
+++ b/internal/util/ptr.go
@@ -17,6 +17,8 @@
package util
+import "unsafe"
+
// EqualPtrs returns whether the values contained within two comparable ptr types are equal.
func EqualPtrs[T comparable](t1, t2 *T) bool {
switch {
@@ -59,3 +61,8 @@ func PtrOrValue[T any](t *T, value T) T {
}
return value
}
+
+func IsNil(i interface{}) bool {
+ type eface struct{ _, data unsafe.Pointer }
+ return (*eface)(unsafe.Pointer(&i)).data == nil
+}