diff options
| author | Alex Flint <[email protected]> | 2021-04-19 21:03:43 -0700 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2021-04-19 21:03:43 -0700 |
| commit | fe4a138ac8c39cb00bbee7279a0957897ab88fae (patch) | |
| tree | 02b48894c636a05751125c495d8325dd2f92fe4f /reflect.go | |
| parent | 6a01a15f75472271568c732c1191e9d33a5fc54c (diff) | |
test coverage 100% !!
Diffstat (limited to 'reflect.go')
| -rw-r--r-- | reflect.go | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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() +} |
