I have found this Error:
ERR wrong number of arguments for 'zadd' command in golang.
This is my code:
defaultPriority:type String
mb.MessageID:type string
mb.EndpointID: type string
_, err = mbDal.redisClient.ZAdd(mb.EndpointID, redis.Z{Score: defaultPriority, Member: mb.MessageID})
if err != nil {
return fmt.Errorf("failed to add mailbox id %s in redis; error %v", mb.MessageID, err)
}
How can I fix this error message?
2
Answers
zadd
is used ingo-redis/redis
, and is defined hereDouble-check your
go.mod
dependencies list.10 months ago, in go-redis v7 (instead of current v8), the signature for that function was:
It used Z instead of (today) *Z.
In your case, you should pass:
I was trying to insert
redis.Z{Score: [an int value], Member: code}
toRedis sorted set
and it failed with that error.So I checked my logic and find out someone calling my method with
code
as an empty string. in my case first insert was successful but after that, all insert failed with that error.github.com/go-redis/redis v6.15.6