未定义:grpc.SupportPackageIsVersion7 grpc.ServiceRegistrar

棚屋:

在docker内部,似乎由于以下错误而无法编译gRPC微服务:

Step 4/9 : RUN make build
 ---> Running in ceb6e4d0e19b
protoc --version
libprotoc 3.12.4
protoc --proto_path=pkg/proto/notify/ --go_out=pkg/proto/notify/ --go-grpc_out=pkg/proto/notify/ --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative notify.proto

plugin versions reported in *.pb.go files:
./pkg/proto/notify/notify.pb.go://  protoc-gen-go v1.25.0-devel
./pkg/proto/notify/notify.pb.go://  protoc        v3.12.4

go build -o notify-service *.go
go: downloading github.com/lib/pq v1.7.0
go: downloading google.golang.org/grpc v1.27.0
go: downloading github.com/jinzhu/gorm v1.9.14
go: downloading github.com/aws/aws-sdk-go v1.33.7
go: downloading github.com/go-kit/kit v0.10.0
go: downloading google.golang.org/protobuf v1.25.0
go: downloading github.com/go-co-op/gocron v0.2.1
go: downloading github.com/sirupsen/logrus v1.6.0
go: downloading github.com/golang/protobuf v1.4.2
go: downloading github.com/matcornic/hermes/v2 v2.1.0
go: downloading github.com/jhillyerd/enmime v0.8.1
go: downloading golang.org/x/sys v0.0.0-20200523222454-059865788121
go: downloading github.com/jaytaylor/html2text v0.0.0-20190408195923-01ec452cbe43
go: downloading github.com/vanng822/go-premailer v0.0.0-20191214114701-be27abe028fe
go: downloading github.com/imdario/mergo v0.3.9
go: downloading github.com/russross/blackfriday/v2 v2.0.1
go: downloading github.com/jinzhu/inflection v1.0.0
go: downloading github.com/Masterminds/sprig v2.16.0+incompatible
go: downloading golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2
go: downloading github.com/PuerkitoBio/goquery v1.5.1
go: downloading github.com/pkg/errors v0.9.1
go: downloading golang.org/x/text v0.3.2
go: downloading github.com/vanng822/css v0.0.0-20190504095207-a21e860bcd04
go: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0
go: downloading github.com/aokoli/goutils v1.0.1
go: downloading google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
go: downloading gopkg.in/gormigrate.v1 v1.6.0
go: downloading github.com/gorilla/css v1.0.0
go: downloading github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf
go: downloading github.com/andybalholm/cascadia v1.1.0
go: downloading github.com/gogs/chardet v0.0.0-20150115103509-2404f7772561
go: downloading golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
go: downloading github.com/olekukonko/tablewriter v0.0.1
go: downloading github.com/cention-sany/utf7 v0.0.0-20170124080048-26cad61bd60a
go: downloading github.com/huandu/xstrings v1.2.0
go: downloading github.com/Masterminds/semver v1.4.2
go: downloading github.com/google/uuid v1.1.1
go: downloading github.com/mattn/go-runewidth v0.0.4
go: downloading github.com/go-logfmt/logfmt v0.5.0
go: downloading github.com/jmespath/go-jmespath v0.3.0
# gitlab.com/kuecr/fero/backend/notify/pkg/proto/notify
pkg/proto/notify/notify_grpc.pb.go:14:11: undefined: grpc.SupportPackageIsVersion7
pkg/proto/notify/notify_grpc.pb.go:71:30: undefined: grpc.ServiceRegistrar
make: *** [Makefile:14: build] Error 2
ERROR: Service 'notify' failed to build: The command '/bin/sh -c make build' returned a non-zero code: 2
make: *** [Makefile:64: build/notify] Error 1

但是,在Docker之外,事物可以运行并成功编译。

这是我的基本Docker映像:

RG go_version

FROM golang:${go_version}-buster

ARG pb_version

RUN apt-get update && apt-get install -y build-essential curl git wget unzip && rm -rf /var/lib/apt/lists/*

RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v${pb_version}/protobuf-cpp-${pb_version}.zip && \
        unzip protobuf-cpp-${pb_version}.zip && \
        cd protobuf-${pb_version} && \
        ./configure  && \
        make  && \
        make check  && \
        make install  && \
        ldconfig && \
        cd ../ && \
        rm -rf protobuf-*

RUN go get github.com/githubnemo/CompileDaemon && \
        go get github.com/golang/protobuf/protoc-gen-go && \
        go get github.com/grpc/grpc-go/cmd/protoc-gen-go-grpc && \
        go install github.com/golang/protobuf/protoc-gen-go && \
        go install github.com/grpc/grpc-go/cmd/protoc-gen-go-grpc

这是完成编译的Docker映像:

FROM registry.gitlab.com/kuecr/devops/go-protobuf-base:1.14 as base

WORKDIR /app

COPY . .

RUN make build

FROM base as testing

ENTRYPOINT ["make", "test"]

FROM base as production

RUN make build

ENTRYPOINT CompileDaemon -log-prefix=false -build="go build -o notify-service" -command="./notify-service"

我的docker和docker-compose和protoc版本:

✖ docker --version && docker-compose --version
Docker version 19.03.12-ce, build 48a66213fe
docker-compose version 1.26.2, build unknown
➜ protoc --version
libprotoc 3.12.4

这是我make build在机器上运行时发生的情况

➜ make build
protoc --version
libprotoc 3.12.4
protoc --proto_path=pkg/proto/notify/ --go_out=pkg/proto/notify/ --go-grpc_out=pkg/proto/notify/ --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative notify.proto

plugin versions reported in *.pb.go files:
./pkg/proto/notify/notify.pb.go://  protoc-gen-go v1.25.0
./pkg/proto/notify/notify.pb.go://  protoc        v3.12.4

go build -o notify-service *.go

我正在使用Golang 1.15,而Docker映像使用1.14。

杰伊·莱恩(Jay Lane):

该错误的要点是,用于生成代码的二进制版本与当前版本的代码不兼容。一种快速简便的解决方案是尝试将protoc-gen-go编译器和gRPC库更新为最新版本。

去获取-u github.com/golang/protobuf/protoc-gen-go

然后重现原形

是指向讨论该问题的reddit线程的链接

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

来自分类Dev

protobuf与gRPC

来自分类Dev

grpc Protobuff 3嵌套消息定义

来自分类Dev

Angular 7 formGroup未定义

来自分类Dev

角度7:未定义注入的服务

来自分类Dev

未定义的ReferenceError未定义

来自分类Javascript

JavaScript:未定义!==未定义?

来自分类Dev

如何访问要定义的Java grpc服务的请求元数据?

来自分类Dev

如何在服务之间共享gRPC原型定义

来自分类Dev

gRPC的Jest模拟失败,并带有手动定义

来自分类Dev

使用gRPC服务定义作为多个实例的接口

来自分类Javascript

Babel 7-ReferenceError:未定义regeneratorRuntime

来自分类Dev

无法读取未定义的属性“长度”-Angular 7

来自分类Dev

架构armv7的未定义符号

来自分类Dev

Cocoapods库的架构armv7的未定义符号

来自分类Dev

架构Armv7 Swift的未定义符号

来自分类Dev

调用未定义的函数odbc_connect()php 7

来自分类Dev

在实体框架7中未定义的OnModelCreating

来自分类Dev

Angular 7错误ReferenceError:未定义SystemJS

来自分类Dev

无法读取未定义角度7的属性

来自分类Dev

Angular 7 NGRX存储具有未定义状态

来自分类Dev

Angular 7 HttpClient获取请求未定义响应

来自分类Dev

GRPC服务继承

来自分类Java

在Maven中使用grpc

来自分类Java

gRPC流被取消

来自分类Java

Java GRPC ServerBuilder与NettyServerBuilder

来自分类Java

与NameResolverProvider相关的gRPC异常

来自分类Dev

Apache Spark和gRPC

来自分类Dev

gRPC的RPC语义

来自分类Dev

Google端点+ GKE + GRPC

TOP 榜单

热门标签

归档