From b9055f22da5b3700bfd6fe4e818b3f0c1a840bbb Mon Sep 17 00:00:00 2001 From: Murtaza Aliakbar Date: Sun, 20 Oct 2024 02:35:24 +0530 Subject: [PATCH] core: IsZero(x) returns true if x is zero value --- intra/core/closer.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/intra/core/closer.go b/intra/core/closer.go index e226a749..6d8b512c 100644 --- a/intra/core/closer.go +++ b/intra/core/closer.go @@ -209,3 +209,11 @@ func TypeEq(a, b any) bool { } return reflect.TypeOf(a) == reflect.TypeOf(b) } + +func IsZero(x any) bool { + if IsNil(x) { + return true + } + v := reflect.ValueOf(x) + return v.IsZero() // panics if x == nil +}