bug fix: null bulk reply bytes

This commit is contained in:
finley
2022-09-30 14:24:55 +08:00
parent dddf9a8f6b
commit f160dcfcc9

View File

@@ -7,7 +7,6 @@ import (
) )
var ( var (
nullBulkReplyBytes = []byte("$-1")
// CRLF is the line separator of redis serialization protocol // CRLF is the line separator of redis serialization protocol
CRLF = "\r\n" CRLF = "\r\n"
@@ -30,7 +29,7 @@ func MakeBulkReply(arg []byte) *BulkReply {
// ToBytes marshal redis.Reply // ToBytes marshal redis.Reply
func (r *BulkReply) ToBytes() []byte { func (r *BulkReply) ToBytes() []byte {
if len(r.Arg) == 0 { if len(r.Arg) == 0 {
return nullBulkReplyBytes return nullBulkBytes
} }
return []byte("$" + strconv.Itoa(len(r.Arg)) + CRLF + string(r.Arg) + CRLF) return []byte("$" + strconv.Itoa(len(r.Arg)) + CRLF + string(r.Arg) + CRLF)
} }