Skip to content

bitpos does not support bit and byteargument #2488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dirkm opened this issue Mar 16, 2023 · 2 comments · Fixed by #2498
Closed

bitpos does not support bit and byteargument #2488

dirkm opened this issue Mar 16, 2023 · 2 comments · Fixed by #2498

Comments

@dirkm
Copy link

dirkm commented Mar 16, 2023

Expected Behavior

I expect bitpos to take start and end prefixes as bits and as bytes

Current Behavior

The interface does not allow to give the last argument bit or byte

Possible Solution

Change the interface to support bit and byte. i.e. with

diff --git a/commands.go b/commands.go
index ac93f39..03a3030 100644
--- a/commands.go
+++ b/commands.go
@@ -192,7 +192,7 @@ type Cmdable interface {
        BitOpOr(ctx context.Context, destKey string, keys ...string) *IntCmd
        BitOpXor(ctx context.Context, destKey string, keys ...string) *IntCmd
        BitOpNot(ctx context.Context, destKey string, key string) *IntCmd
-       BitPos(ctx context.Context, key string, bit int64, pos ...int64) *IntCmd
+      BitPos(ctx context.Context, key string, args ...interface{}) *IntCmd
        BitField(ctx context.Context, key string, args ...interface{}) *IntSliceCmd

Steps to Reproduce

Below is the syntax using redis-cli:

$ redis-cli 
127.0.0.1:6379> Set mykey '\xff\xf0\x00' 
OK
127.0.0.1:6379> bitpos mykey 0 0 2 byte
(integer) 0
127.0.0.1:6379> bitpos mykey 0 0 2 bit
(integer) 0
127.0.0.1:6379> 

Context (Environment)

My code is more complex then it needs to be because offsets in bits are not supported.

@monkey92t
Copy link
Collaborator

fix by #2498

@dirkm
Copy link
Author

dirkm commented Mar 23, 2023

thank you for the quick patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants