nitishm / go-rejson

Golang client for redislabs' ReJSON module with support for multilple redis clients (redigo, go-redis)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-redis/v9 compatibility

pulpfree opened this issue · comments

I noticed you used go-redis/v9 in your examples and hoped to do the same.
When calling: jsonh.SetGoRedisClientWithContext(context.Background(), client)

I get the following error:
cannot use client (variable of type *"github.com/redis/go-redis/v9".Client) as clients.GoRedisClientConn value in argument to jsonh.SetGoRedisClientWithContext: *"github.com/redis/go-redis/v9".Client does not implement clients.GoRedisClientConn (wrong type for method Do). have Do(context.Context, ...interface{}) *"github.com/redis/go-redis/v9".Cmd. want Do(context.Context, ...interface{}) *"github.com/go-redis/redis/v8".Cmd

Also, in my go.mod file after running go mod tidy
I got the v8 installed as an indirect dependency

Here's my Redis Client setup:

jsonh := rejson.NewReJSONHandler()

rdb.setConnectUri()
opt, err := redis.ParseURL(rdb.connectUri)

client := redis.NewClient(opt)
jsonh.SetGoRedisClientWithContext(context.Background(), client)

So curious as to why this works in your examples, but I'm unable to do the same.

Thanks,
Ron

Curious 🤔

Can you provide a small program with go modules that replicates the error? I feel like it's related to the versions you're using.

Sure view test repo

This repo is based on the subgraph-go-gqlgen template for building gqlgen graphs

commented

Hi I had this same problem and was able to resolve it. Looks like it is caused because there is no new tag after the v9 upgrade was done. When users run go get github.com/nitishm/go-rejson/v4 they'll get the latest tag build (v4.1.0), which is like a year old. Users can workaround this by running: go get github.com/nitishm/go-rejson/v4@master to get the latest commit on the master branch. Or someone can add a new tag, then people can just pull from that.

@unitoftime Thanks bud, was on my way to downgrade to go-redis v8 but your solution did work for me

@Shivam010 could you please release a new tag, to include the PR #72 ?