如何导入gRPC空白和Google API注释原始

问题描述:

我试图使用Google Cloud Endpoints来制作基于gRPC的API,可以transcode incoming REST requests。我正在关注their example code,但我无法通过任何关于如何正确导入和编译annotation.proto或empty.proto的文档。如何导入gRPC空白和Google API注释原始

谢谢!

我不明白这是grpc-gateway的一部分。通过following the docs我跑

protoc -I/usr/local/include -I. -I$GOPATH/src -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=plugins=grpc:. *.proto 

并编译成功。

默认情况下不包含empty.proto和annotation.proto,因此您需要提供一份副本。具体而言,您可以在项目目录中复制它们,或者在现有项目中引用它们(例如Protobuf git repo)。

这可能是一个好主意不是参考grpc-ecosystem/grpc-gateway使用的副本,因为他们可能想在将来移动它。