Browse Source

Add IsEmpty; Publish 0.8.1

pull/1780/head
Jae Kwon 7 years ago
parent
commit
2e24b64fc1
2 changed files with 12 additions and 0 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +11
    -0
      common/nil.go

+ 1
- 0
CHANGELOG.md View File

@ -5,6 +5,7 @@
FEATURES:
- [common] Error.Error() includes cause
- [common] IsEmpty() for 0 length
## 0.8.0 (develop branch)


+ 11
- 0
common/nil.go View File

@ -16,3 +16,14 @@ func IsTypedNil(o interface{}) bool {
return false
}
}
// Returns true if it has zero length.
func IsEmpty(o interface{}) bool {
rv := reflect.ValueOf(o)
switch rv.Kind() {
case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice, reflect.String:
return rv.Len() == 0
default:
return false
}
}

Loading…
Cancel
Save