协议(protocol) --gogofaster_out=。图片.proto
我收到此错误消息
/home/abc/src/github.com/gogo/protobuf/gogoproto/gogo.proto: File not found.
image.proto: Import "/home/abc/src/github.com/gogo/protobuf/gogoproto/gogo.proto" was not found or had errors.
文件肯定在那里。我可以从错误中报告的路径到达它。
我的原型(prototype)文件是这样的:
package image;
import "/home/abc/src/github.com/gogo/protobuf/gogoproto/gogo.proto";
message Frame {
required bool fragment = 1;
required int32 fragmentID = 2;
required bool lastFragment = 3;
required bytes data = 4;
}
我在原始文件所在的目录中有一个Makefile
。看起来像这样:
regenerate:
--proto_path=../../github.com/gogo/protobuf/gogoproto:../../github.com/gogo/protobuf/protobuf/google/protobuf:. --gogofaster_out=. *.proto
如何解决路径错误?
最佳答案
作为in this issue ,您可以尝试仅导入相对路径:
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
首先确保GOPATH
设置为/home/abc
。
我提到 protobuf PR 241 ,其中 makefile 定义了要使用的 PATH:
regenerate:
protoc-min-version --version="3.0.0"
--proto_path=$(GOPATH)/src/image:
$(GOPATH)/src/github.com/gogo/protobuf/protobuf:
$(GOPATH)/src/github.com/gogo/protobuf/protobuf/google/protobuf:
. --gogo_out=. *.proto
OP 提及 this thread ,它指出:
The dependencies call other dependencies in "
google/protobuf/
", so these need to be in the path correctly also.
The errors are pretty misleadingAlso when using gogoproto extensions you should use
gogofast_out
.
gofast_out
is only for when you are not using any extensions, but want some extra speed.
gogofast_out
/gofast_out
has no side effects.
gogofaster_out
makes most fieldsnullable=false
.
关于gogo.proto : File not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43026449/