summaryrefslogtreecommitdiff
path: root/reflect.go
diff options
context:
space:
mode:
Diffstat (limited to 'reflect.go')
-rw-r--r--reflect.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/reflect.go b/reflect.go
index 1806973..c719b52 100644
--- a/reflect.go
+++ b/reflect.go
@@ -94,3 +94,15 @@ func isExported(field string) bool {
r, _ := utf8.DecodeRuneInString(field) // returns RuneError for empty string or invalid UTF8
return unicode.IsLetter(r) && unicode.IsUpper(r)
}
+
+// isZero returns true if v contains the zero value for its type
+func isZero(v reflect.Value) bool {
+ t := v.Type()
+ if t.Kind() == reflect.Slice || t.Kind() == reflect.Map {
+ return v.IsNil()
+ }
+ if !t.Comparable() {
+ return false
+ }
+ return v.Interface() == reflect.Zero(t).Interface()
+}