I was using confluent kafka package for my data streaming server in golang using ubuntu 20.04 and now I changed my os to ubuntu 22.04.
Now im getting these errors:
- kafka.producer/producer.go:18:26: undefined: kafka.Producer
- kafka.producer/producer.go:35:17: undefined: kafka.ConfigMap
- kafka.producer/producer.go:40:30: undefined: kafka.NewProducer
- kafka.producer/producer.go:133:50: undefined: kafka.Message
- kafka.producer/producer.go:134:27: undefined: kafka.TopicPartition
- kafka.producer/producer.go:136:23: undefined: kafka.PartitionAny
But the segmentio package is working fine in the same code. The thing is I want to use confluent package because it has subscribe and unsubscribe features, which I felt advantage over the segemntio package.
Does anyone knows how to fix this error?
Since the
github.com/confluentinc/confluent-kafka-go/v2/kafkapackage uses bindings on-top of thelibrdkafkaC library, you have to make sure cgo is configured correctly first.The common things to check are:
make sure cgo is enabled (
CGO_ENABLED="1"):make sure the C compiler is available. run
go env CCto see which C compiler is used.Besides checking cgo, it's also necessary to make sure
librdkafkais available. See build tags: