安装依赖

confluent_kafka需要pkg-config和librdkafka,confluent_kafka只能在linux用,顺便吐槽一下,windows上的go有点坑。
首先安装pkg-config
sudo yum install pkg-config
然后安装librdkafka,需要导入confluent的源,这种方法可能会出现版本太老的问题,所以使用另外的编译安装方法

git clone https://github.com/edenhill/librdkafka.git
cd librdkafka
./configure
make -j 2
make install
sudo ldconfig

不可用
sudo rpm --import https://packages.confluent.io/rpm/5.3/archive.key
vim /etc/yum.repos.d/confluent.repo

[Confluent.dist]
name=Confluent repository (dist)
baseurl=https://packages.confluent.io/rpm/5.3/7
gpgcheck=1
gpgkey=https://packages.confluent.io/rpm/5.3/archive.key
enabled=1

[Confluent]
name=Confluent repository
baseurl=https://packages.confluent.io/rpm/5.3
gpgcheck=1
gpgkey=https://packages.confluent.io/rpm/5.3/archive.key
enabled=1

sudo yum makecache
sudo yum install -y librdkafka-devel

安装go

go get -u gopkg.in/confluentinc/confluent-kafka-go.v1/kafka