diff options
| author | Alex Flint <[email protected]> | 2021-04-19 21:27:53 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-04-19 21:27:53 -0700 |
| commit | a0937d1b588cbb39c0fb9c250ebf21dce42b7dab (patch) | |
| tree | bb658d951719fb3d0b4ed90df9aded48d4bbaeb1 /reflect.go | |
| parent | 6a01a15f75472271568c732c1191e9d33a5fc54c (diff) | |
| parent | 01a9fab8d768fbcb11e51d4df3c8fda6230462da (diff) | |
Merge pull request #150 from alexflint/push-coverage-up-more
Push test coverage up to 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() +} |
