英文:
Error installing golang Shopify/sarama Kafka library
问题
在安装golang
的github.com/Shopify/sarama
kafka
库时遇到以下错误:
go get github.com/Shopify/sarama
# github.com/Shopify/sarama
go/src/github.com/Shopify/sarama/config.go:678:37: undefined: io.Discard
go/src/github.com/Shopify/sarama/decompress.go:43:10: undefined: io.ReadAll
go/src/github.com/Shopify/sarama/decompress.go:55:10: undefined: io.ReadAll
go/src/github.com/Shopify/sarama/sarama.go:89:29: undefined: io.Discard
这个错误是由于io.Discard
和io.ReadAll
未定义导致的。
英文:
Getting following error when installing golang
github.com/Shopify/sarama
kafka
library
go get github.com/Shopify/sarama
# github.com/Shopify/sarama
go/src/github.com/Shopify/sarama/config.go:678:37: undefined: io.Discard
go/src/github.com/Shopify/sarama/decompress.go:43:10: undefined: io.ReadAll
go/src/github.com/Shopify/sarama/decompress.go:55:10: undefined: io.ReadAll
go/src/github.com/Shopify/sarama/sarama.go:89:29: undefined: io.Discard
答案1
得分: 1
ioutil.Discard
和ioutil.ReadAll
已经在Go 1.16中移动到io.Discard
和io.ReadAll
,
你应该使用Go 1.16或者使用一个较旧的版本的sarama(我认为v1.20.1应该适用于go1.13)
此外,根据sarama的README:
> Sarama提供了“2个发布版本+2个月”的兼容性保证:我们支持Kafka和Go的最新的两个稳定版本,并为较旧的版本提供两个月的宽限期。这意味着我们目前正式支持Go 1.15到1.16,Kafka 2.7到2.8,尽管较旧的版本仍然可能可以工作。
英文:
ioutil.Discard
and ioutil.ReadAll
has moved to io.Discard
and io.ReadAll
respectively as of Go 1.16,
You should use Go 1.16 or use an older version of sarama (I think v1.20.1 should work for go1.13)
Also from sarama's README:
> Sarama provides a "2 releases + 2 months" compatibility guarantee: we
> support the two latest stable releases of Kafka and Go, and we provide
> a two month grace period for older releases. This means we currently
> officially support Go 1.15 through 1.16, and Kafka 2.7 through 2.8,
> although older releases are still likely to work.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论