英文:
Go + Redis - Tutorial Get Started doesn't work
问题
你好,
我制作了几个关于Redis和Go的教程网站。
其中大部分页面都无法正常工作。
这是一个非常简单的无法工作的示例。
https://developer.redis.com/develop/golang/
以下是错误信息:
# command-line-arguments
./main.go:17:29: 调用client.cmdable.Ping时参数过多
已有 (context.Context)
期望 ()
如何使教程正常工作?
英文:
Hi,
I have made several redis and go tutorial sites.
Most of the pages don't work.
Here's a very simple one that doesn't work.
https://developer.redis.com/develop/golang/
And here is the error message.
# command-line-arguments
./main.go:17:29: too many arguments in call to client.cmdable.Ping
have (context.Context)
want ()
How to make the tutorial work?
答案1
得分: 2
你使用的是哪个版本的go-redis?在版本8中应该可以工作。github.com/go-redis/redis/v8
。
请参考这个示例代码,了解如何使用它:https://github.com/go-redis/redis/blob/master/example_test.go
在go-redis
的v1
版本中,函数签名不包括context.Context
。查看代码。你很可能导入了没有v8后缀的go redis,因此导入了go-redis v1(在go中,库的v1版本不需要v...
后缀)。
英文:
What version of go-redis are you using? In version 8 it should work.
github.com/go-redis/redis/v8
.
See this example code on how to use it: https://github.com/go-redis/redis/blob/master/example_test.go
In v1
of go-redis
the function signature does not include context.Context
. See the code. You've most likely imported go redis without the v8 suffix, thus importing go-redis v1. (in go the v1 version of a library does not require the v...
suffix).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论