几周前我也遇到过类似的问题。IIRC
confluent-kafka-go需要最新版本的
librdkafka-dev,但尚未发布给高山或其他人。虽然我能够为ubuntu找到它,所以我的解决方案(它比我期望的要复杂得多,但它确实有效)是从干净的ubuntu开始,安装
librdkafka-dev,安装我想要的Go版本并在docker中编译。
外观如下:
FROM ubuntu# Install the C lib for kafkaRUN apt-get updateRUN apt-get install -y --no-install-recommends apt-utils wget gnupg software-properties-commonRUN apt-get install -y apt-transport-https ca-certificatesRUN wget -qO - https://packages.confluent.io/deb/5.1/archive.key | apt-key add -RUN add-apt-repository "deb [arch=amd64] https://packages.confluent.io/deb/5.1 stable main"RUN apt-get updateRUN apt-get install -y librdkafka-dev# Install GoRUN add-apt-repository ppa:longsleep/golang-backportsRUN apt-get updateRUN apt-get install -y golang-1.11-go# build the libraryWORKDIR /go/src/gitlab.appsflyer.com/rantav/kafka-mirror-testerCOPY *.go ./COPY // the rest of your go files. You may copy recursive if you wantCOPY vendor vendorRUN GOPATH=/go GOOS=linux /usr/lib/go-1.11/bin/go build -a -o main .EXPOSE 8000ENTRYPOINT ["./main"]



