2017-03-26 199 views
1

protoc --gogofaster_out=. image.protogogo.proto:未找到文件

我收到此错误信息

/home/abc/src/github.com/gogo/protobuf/gogoproto/gogo.proto:未找到文件。

image.proto:导入“/home/abc/src/github.com/gogo/protobuf/gogoproto/gogo.proto”未找到或有错误。

该文件绝对存在。我可以从错误中报告的路径中找到它。

我的原文件是这样的:

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 

我该怎么做才能解决路径错误?

回答

0

由于in this issue,你可以尝试只导入相对路径:

import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 

确保GOPATH设置为/home/abc第一。

我提到protobuf PR 241,这里的Makefile定义要使用的路径:

​​

的OP提this thread,其中指出:

的依赖调用其他依赖于 “google/protobuf/”,所以这些也需要正确的路径。
错误是相当误导

此外,当使用gogoproto扩展您应该使用gogofast_out
gofast_out仅适用于未使用任何扩展名,但希望获得一些额外速度的情况。
gogofast_out/gofast_out没有副作用。
gogofaster_out制作于大部分字段nullable=false

+0

相对路径相同的错误。您发布的问题链接对我无效。 – user3017869

+0

@ user3017869是否正确设置了GOPATH?你使用什么版本的Go? “/ home/abc/src/github.com/gogo/protobuf/gogoproto/gogo.proto”的路径和文件是可访问和可读的吗? – VonC

+0

'GOPATH'设置正确。 Go版本是1.8。 gogo.proto是可访问和可读的 – user3017869