cbl*_*bll 18 go protocol-buffers grpc
按照有关如何设置 gRPC 网关的文档,我发现自己陷入了生成 grpc 网关的第四步。
也就是说,当添加以下行时,事情就会崩溃:
import "google/api/annotations.proto";
Run Code Online (Sandbox Code Playgroud)
该文档说了You will need to provide the required third party protobuf files to the protoc compiler- 但实际上并没有说明如何做到这一点。
如何添加google/api/annotations.proto为依赖项?
cbl*_*bll 16
我通过将第三方 google api及其内容添加到我的项目的根目录中解决了这个问题。
感觉不对,但显然这是鼓励的
Ins*_* IT 10
我遇到了同样的问题,并按照以下结构解决了它:
\nproto\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 google\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 api\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 annotations.proto\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 http.proto\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 helloworld\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 hello_world.proto\nRun Code Online (Sandbox Code Playgroud)\n并运行命令:
\nprotoc -I ./proto \\\n --go_out ./proto --go_opt paths=source_relative \\\n --go-grpc_out ./proto --go-grpc_opt paths=source_relative \\\n --grpc-gateway_out ./proto --grpc-gateway_opt paths=source_relative \\\n ./proto/helloworld/hello_world.proto\nRun Code Online (Sandbox Code Playgroud)\n