diff --git a/util.go b/util.go index b15fd9a..faa0e58 100644 --- a/util.go +++ b/util.go @@ -9,7 +9,6 @@ import ( "errors" "fmt" "reflect" - "time" ) var ( @@ -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 diff --git a/util_test.go b/util_test.go index fa4a047..f7bde4b 100644 --- a/util_test.go +++ b/util_test.go @@ -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 { @@ -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},