Skip to content

Commit

Permalink
core: IsZero(x) returns true if x is zero value
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Oct 19, 2024
1 parent 13f0eae commit b9055f2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions intra/core/closer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit b9055f2

Please sign in to comment.