File does not reside within any path specified using proto_path

て烟熏妆下的殇ゞ 提交于 2019-12-07 05:33:24

问题


I am testing out importing .proto file from another directory.

$GOPATH/src/A/A.proto

syntax = "proto3"; 
package A;
 message SomeMsg {
     string  msg = 2;
     int64   id  = 3;
 }

$GOPATH/src/B/B.proto

syntax = "proto3"; 
package B; import "A/A.proto";
 message Msg {
     SomeMsg s = 1;
 }

I'm doing this: in folder A:

protoc A.proto --go_out=.

and then in folder B:

protoc B.proto --go_out=. --proto_path=$GOPATH/

But I will get this error:

B.proto: File does not reside within any path specified using --proto_path (or -I). You must specify a --proto_path which encompasses this file. Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think).


回答1:


Error seems clear enough to me, it is saying that you need to specify the exact directory that B.proto is in

protoc B.proto --go_out=. --proto_path=$GOPATH/src/B 

or if you are in folder B already,

protoc B.proto --go_out=.


来源:https://stackoverflow.com/questions/51287288/file-does-not-reside-within-any-path-specified-using-proto-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!