【爬坑记录】grpc-gateway 出现google/protobuf/descriptor.proto: File not found.

本地跑该项目出现类似如下错误



```csharp
google/protobuf/descriptor.proto: File not found. 
解决方法(mac os):

brew install protobuf@3.1
cd /usr/local/Cellar/protobuf@3.1/3.1.0
sudo cp bin/protoc /usr/local/bin/
sudo rm -r /usr/local/include/google/protobuf/
sudo cp -r include/google/protobuf/ /usr/local/include/google/protobuf/
sudo cp -r lib /usr/local/

发布了32 篇原创文章 · 获赞 6 · 访问量 2万+
展开阅读全文

在golang中导入“ google / protobuf / descriptor.proto”

10-19

<div class="post-text" itemprop="text"> <p>I'm using <a href="https://developers.google.com/protocol-buffers/docs/proto?hl=cs#options" rel="nofollow noreferrer">custom options</a> to define swagger annotations for my proto service definition. </p> <p>There is already an implementation of this <a href="https://github.com/grpc-ecosystem/grpc-gateway/blob/master/protoc-gen-swagger/options/annotations.proto" rel="nofollow noreferrer">swagger annotations</a> so I just need to import this implementation on my .proto service definition</p> <pre><code>import "protoc-gen-swagger/options/annotations.proto"; ... </code></pre> <p>The problem is that this library has a dependency of <strong>google/protobuf/descriptor.proto</strong> and this descriptor library was created on <strong>proto2</strong> specification(this library is from the protocolbuffers/protobuf <a href="https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/descriptor.proto" rel="nofollow noreferrer">project</a>)</p> <pre><code>syntax = "proto2"; package google.protobuf; </code></pre> <p>so when I tried to build the proto for php I receive the error:</p> <pre><code>-php_out: google/protobuf/descriptor.proto: Can only generate PHP code for proto3 .proto files. Please add 'syntax = "proto3";' to the top of your .proto file. </code></pre> <p>Does anyone know where I can find the proto definition of <strong>google/protobuf/descriptor.proto</strong> on proto buffers version 3? o how can I resolve this issue?</p> </div> 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 技术工厂 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览