// 报错样式:
panic: non-positive interval for NewTicker
goroutine 59 [running]:
time.NewTicker(0x0, 0x0)
D:/Go/src/time/tick.go:23 +0x14e
github.com/bsm/sarama-cluster.(*Consumer).cmLoop(0xc000212000, 0xc0002ba1e0)
D:/work/mygo/pkg/mod/github.com/bsm/sarama-cluster@v2.1.15+incompatible/consumer.go:452 +0x61
github.com/bsm/sarama-cluster.(*loopTomb).Go.func1(0xc0002982a0, 0xc000288230)
D:/work/mygo/pkg/mod/github.com/bsm/sarama-cluster@v2.1.15+incompatible/util.go:73 +0x82
created by github.com/bsm/sarama-cluster.(*loopTomb).Go
D:/work/mygo/pkg/mod/github.com/bsm/sarama-cluster@v2.1.15+incompatible/util.go:69 +0x6d
//处理1: 找到这个consumer.go源码位置,上面的第二个报错有标注位置
github.com/bsm/sarama-cluster.(*Consumer).cmLoop(0xc000212000, 0xc0002ba1e0)
D:/work/mygo/pkg/mod/github.com/bsm/sarama-cluster@v2.1.15+incompatible/consumer.go:452 +0x61
// 修改452行,
// ticker := time.NewTicker(c.client.config.Consumer.Offsets.CommitInterval)
ticker := time.NewTicker(c.client.config.Consumer.Offsets.AutoCommit.Interval)
// 保存重新build即可
另有方案:
把 sarama 版本改成 从 v1.26.1 --> v1.24.1 就可以用啦 github.com/Shopify/sarama v1.24.1
gomod 的配置改下版本号就可以
github.com/Shopify/sarama v1.24.1
github.com/bsm/sarama-cluster v2.1.15+incompatible
参考: sarama-cluster消费者运行时报panic