reflective: IsZero()

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-09-02 22:04:16 +00:00
parent a38f0c74e8
commit 667803fea5
+15
View File
@@ -0,0 +1,15 @@
package reflective
import "reflect"
// IsZero tells if a value is zero either via
// v.IsZero() or reflection.
func IsZero(iv any) bool {
if p, ok := iv.(interface {
IsZero() bool
}); ok {
return p.IsZero()
}
return reflect.ValueOf(iv).IsZero()
}