gpt4 book ai didi

go - 错误 'zadd'命令的参数数目错误

转载 作者:行者123 更新时间:2023-12-01 21:14:01 26 4
gpt4 key购买 nike

我发现此错误:

ERR wrong number of arguments for 'zadd' command in golang.

这是我的代码:
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)
}

如何解决此错误消息?

最佳答案

zadd is used in go-redis/redis ,是defined here

// Redis `ZADD key score member [score member ...]` command.
func (c cmdable) ZAdd(key string, members ...*Z) *IntCmd {

仔细检查您的 go.mod依赖关系列表。
10个月前,在go-redis v7(而不是当前的v8)中, signature for that function was:
 func (c *cmdable) ZAdd(key string, members ...Z) *IntCmd {

它使用Z代替(今天)* Z。

就您而言,您应该通过:
&redis.Z{Score: defaultPriority, Member: mb.MessageID}

关于go - 错误 'zadd'命令的参数数目错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60800880/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com