Skip to content

Commit

Permalink
✨ feat: IsEmptyReal and IsZeroReal method (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
KiddoV authored May 17, 2024
1 parent 68ce124 commit f480138
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions check.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ func IsEmpty(v any) bool {
return reflects.IsEmpty(reflect.ValueOf(v))
}

// Alias of the IsEmptyReal()

Check warning on line 29 in check.go

View workflow job for this annotation

GitHub Actions / Test on go 1.20 and ubuntu-latest

comment on exported var IsZeroReal should be of the form "IsZeroReal ..."
var IsZeroReal = IsEmptyReal

// IsEmptyReal checks for empty given value and also real empty value if the passed value is a pointer
func IsEmptyReal(v any) bool {
if v == nil {
return true
}
return reflects.IsEmptyReal(reflect.ValueOf(v))
}

// IsFunc value
func IsFunc(val any) bool {
if val == nil {
Expand Down
4 changes: 4 additions & 0 deletions check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ func TestIsEmpty(t *testing.T) {
is.True(goutil.IsEmpty(nil))
is.False(goutil.IsZero("abc"))
is.False(goutil.IsEmpty("abc"))

is.True(goutil.IsEmptyReal(nil))
is.False(goutil.IsZeroReal("abc"))
is.False(goutil.IsEmptyReal("abc"))
}

func TestIsFunc(t *testing.T) {
Expand Down

0 comments on commit f480138

Please sign in to comment.