安装golang Shopify/sarama Kafka库时出现错误。

huangapple go评论78阅读模式
英文:

Error installing golang Shopify/sarama Kafka library

问题

在安装golanggithub.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.Discardio.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.Discardioutil.ReadAll已经在Go 1.16中移动到io.Discardio.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.

huangapple
  • 本文由 发表于 2021年9月26日 04:34:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/69329817.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定