From d5358ff27d215d52f56696e4260fc24ad3c6b006 Mon Sep 17 00:00:00 2001 From: hible <514366607@qq.com> Date: Fri, 5 May 2023 20:40:51 +0800 Subject: [PATCH] Update command.go --- command.go | 12 ++++++++---- commands_test.go | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/command.go b/command.go index 1fc32558..7b351976 100644 --- a/command.go +++ b/command.go @@ -1452,12 +1452,16 @@ func readXMessageSlice(rd *proto.Reader) ([]XMessage, error) { return nil, err } - msgs := make([]XMessage, n) - for i := 0; i < len(msgs); i++ { - if msgs[i], err = readXMessage(rd); err != nil { - return nil, err + msgs := make([]XMessage, 0, n) + for i := 0; i < n; i++ { + if xMessage, err := readXMessage(rd); err == nil { + msgs = append(msgs, xMessage) } } + if len(msgs) < 1 { + // Compatible with previous returns + return nil, proto.Nil + } return msgs, nil } diff --git a/commands_test.go b/commands_test.go index a2abe1b0..d8fd1b52 100644 --- a/commands_test.go +++ b/commands_test.go @@ -5691,7 +5691,7 @@ var _ = Describe("Commands", func() { Stream: "stream", Group: "group", Consumer: "consumer", - Messages: []string{"1-0", "2-0", "3-0"}, + Messages: []string{"???-???", "1-0", "2-0", "3-0"}, }).Result() Expect(err).NotTo(HaveOccurred()) Expect(msgs).To(Equal([]redis.XMessage{{