我正在测试从另一个目录导入.proto文件 .
$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;
}
我这样做:在文件夹A中:
protoc A.proto --go_out=.
然后在文件夹B中:
protoc B.proto --go_out=. --proto_path=$GOPATH/
但我会得到这个错误:
B.proto:文件不驻留在使用--proto_path(或-I)指定的任何路径中 . 您必须指定包含此文件的--proto_path . 请注意,proto_path必须是.proto文件名的确切前缀 - protoc太笨了,无法确定两条路径(例如绝对路径和相对路径)是否相等(它比您想象的更难) .
1 回答
错误对我来说似乎很清楚,它说你需要指定B.proto所在的确切目录
或者如果你已经在文件夹B中,
protoc家伙很有趣 it's harder than you think !!!哈哈,为什么我要争取说出来的愿望"That's what she said!"哈哈