Skip to content

Commit b9055f2

Browse files
committed
core: IsZero(x) returns true if x is zero value
1 parent 13f0eae commit b9055f2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

intra/core/closer.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,11 @@ func TypeEq(a, b any) bool {
209209
}
210210
return reflect.TypeOf(a) == reflect.TypeOf(b)
211211
}
212+
213+
func IsZero(x any) bool {
214+
if IsNil(x) {
215+
return true
216+
}
217+
v := reflect.ValueOf(x)
218+
return v.IsZero() // panics if x == nil
219+
}

0 commit comments

Comments
 (0)