diff --git a/commands.go b/commands.go index 034daa235..3e5a4b363 100644 --- a/commands.go +++ b/commands.go @@ -153,6 +153,8 @@ func isEmptyValue(v reflect.Value) bool { return v.Float() == 0 case reflect.Interface, reflect.Pointer: return v.IsNil() + case reflect.Struct: + return v.IsZero() } return false } diff --git a/commands_test.go b/commands_test.go index 829a94b65..87768cc72 100644 --- a/commands_test.go +++ b/commands_test.go @@ -2517,6 +2517,19 @@ var _ = Describe("Commands", func() { "val2", "val", })) + + type set2 struct { + Set1 string `redis:"set1"` + Set2 int `redis:"set2,omitempty"` + Set3 time.Duration `redis:"set3,omitempty"` + Set4 string `redis:"set4,omitempty"` + Set5 time.Time `redis:"set5,omitempty"` + } + hSet = client.HSet(ctx, "hash3", &set{ + Set1: "val", + }) + Expect(hSet.Err()).NotTo(HaveOccurred()) + Expect(hSet.Val()).To(Equal(int64(1))) }) It("should HSetNX", func() {