I'm using the redigo
redis library, and checking if a key is already present in a redis set
. I'm using the redis command SISMEMBER
via the redigo's Do
method which returns an interface. It is the response of the command being executed using Do
. In case of SISMEMBER
command, the response in a 1
or 0
. and in this particular case, the response is 0
as the given key is not present in this set. however reflect.DeepEqual(resp, 0)
is returning false
when true
is expected. Is this not the correct way to use DeepEqual
function?
import (
"fmt"
"reflect"
"github.com/garyburd/redigo/redis"
)
func main() {
conn, err := redis.Dial("tcp", "127.0.0.1:6379")
if err != nil {
fmt.Println(err.Error())
return
}
defer conn.Close()
resp, err := conn.Do("SISMEMBER", "mySet", "Hello")
if reflect.DeepEqual(resp, 0) {
fmt.Println("record doesn't exist")
}
}