Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"errors"
"fmt"
"reflect"
"time"
)

var (
Expand Down Expand Up @@ -117,10 +116,7 @@ func IsEmpty(value interface{}) bool {
}
return IsEmpty(v.Elem().Interface())
case reflect.Struct:
v, ok := value.(time.Time)
if ok && v.IsZero() {
return true
}
return v.IsZero()
}

return false
Expand Down
9 changes: 6 additions & 3 deletions util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ func TestIsEmpty(t *testing.T) {
var s1 string
var s2 = "a"
var s3 *string
s4 := struct{}{}
s4 := struct{A string}{}
s5 := struct{A string}{A: "a"}
time1 := time.Now()
var time2 time.Time
tests := []struct {
Expand Down Expand Up @@ -251,8 +252,10 @@ func TestIsEmpty(t *testing.T) {
{"t8.2", &s2, false},
{"t8.3", s3, true},
// struct
{"t9.1", s4, false},
{"t9.2", &s4, false},
{"t9.1", s4, true},
{"t9.2", &s4, true},
{"t9.3", s5, false},
{"t9.4", &s5, false},
// time.Time
{"t10.1", time1, false},
{"t10.2", &time1, false},
Expand Down