Skip to content

Commit

Permalink
fix: #2956 (#2957)
Browse files Browse the repository at this point in the history
Signed-off-by: monkey92t <golang@88.com>
Co-authored-by: Vladimir Mihailenco <vladimir.webdev@gmail.com>
  • Loading branch information
monkey92t and vmihailenco committed Apr 6, 2024
1 parent 683f4fa commit 6833d2f
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions bitmap_commands.go
Expand Up @@ -45,22 +45,19 @@ const BitCountIndexByte string = "BYTE"
const BitCountIndexBit string = "BIT"

func (c cmdable) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd {
args := []interface{}{"bitcount", key}
args := make([]any, 2, 5)
args[0] = "bitcount"
args[1] = key
if bitCount != nil {
if bitCount.Unit == "" {
bitCount.Unit = "BYTE"
}
if bitCount.Unit != BitCountIndexByte && bitCount.Unit != BitCountIndexBit {
cmd := NewIntCmd(ctx)
cmd.SetErr(errors.New("redis: invalid bitcount index"))
return cmd
args = append(args, bitCount.Start, bitCount.End)
if bitCount.Unit != "" {
if bitCount.Unit != BitCountIndexByte && bitCount.Unit != BitCountIndexBit {
cmd := NewIntCmd(ctx)
cmd.SetErr(errors.New("redis: invalid bitcount index"))
return cmd
}
args = append(args, bitCount.Unit)
}
args = append(
args,
bitCount.Start,
bitCount.End,
string(bitCount.Unit),
)
}
cmd := NewIntCmd(ctx, args...)
_ = c(ctx, cmd)
Expand Down

0 comments on commit 6833d2f

Please sign in to comment.