dongqian5569 2018-07-11 13:52
浏览 1129
已采纳

文件不在使用proto_path指定的任何路径内

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条回答 默认 最新

  • douyingtai6662 2018-07-11 15:37
    关注

    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=.
    

    The protoc guys are funny it's harder than you think!!! Lol, why am I fighting the desire to say "That's what she said!" Lol

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?