2017-03-26 195 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