Suppose I have a bitmap that I have set using the following commands
setbit key 0 1
setbit key 1 1
setbit key 2 0
setbit key 3 1
setbit key 4 1
When I run get on this key from the redis-cli I get the following result: "\xd8"
But when I do it using a go-redis API I get a different result which is this: � @
To get the above result I have used the following code:
package main
import (
"fmt"
"github.com/go-redis/redis"
)
func main() {
client := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "",
DB: 0,
})
pong, _ := client.Ping().Result()
fmt.Println(pong)
client.SetBit("key", 0, 1)
client.SetBit("key", 1, 1)
client.SetBit("key", 2, 0)
client.SetBit("key", 3, 1)
client.SetBit("key", 4, 1)
res := client.Get("bmk").Val()
fmt.Println(res)
}
I cannot find it anywhere in the redis docs which kind of encoding the cli uses to produce such results. I would like to convert the results to the same format in my go program as well.
Can someone please tell me what kind of encoding this is and how can I convert the result received from the Redis API to the one obtained by the CLI ?