Alejandro Mery
1 year ago
1 changed files with 15 additions and 0 deletions
@ -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() |
||||
} |
Loading…
Reference in new issue