One - One Code All

Blog Content

github.com/gogo/protobuf/gogoproto/gogo.proto: File not found.

Go   2018-09-08 14:43:45

安装gogoprotobuf:

go get github.com/gogo/protobuf/proto
go get github.com/gogo/protobuf/gogoproto
go get github.com/gogo/protobuf/protoc-gen-gogo
go get github.com/gogo/protobuf/protoc-gen-gofast


写proto时,有时候需要引入其它proto,之后会发现goland提示import路径不存在,报错:github.com/gogo/protobuf/gogoproto/gogo.proto: File not found.


这里只是goland插件提示而已,与实际生成无关,只需要在插件路径中,加入你proto的路径即可。首选项-> Language & frameworks -> Protocol Buffers, configure automatically前面的勾去掉,添加插件路径。


而在实际生成pb文件时,只需要在命令中,通过-I加入关联的目录即可,

protoc --go_out=plugins=grpc:. -I=${GOPATH}/src -I=. *.proto

protoc --go_out=.  -I=/Users/grantbai/go/src -I=.  model/base_model/proto/*.proto

-I , 大写的i 。

protoc --go_out=../ --proto_path=./model/proto  -I=/Users/grantbai/go/src -I=./strategy/martingale *.proto


-I 引入两个目录,一个是要引入的插件目录, 一个是要编译的 proto 文件所在目录。如果引用了其他的文件,还需要引入该位置,省事的方式是引入根目录,即:-I=.



参考示例:https://github.com/protocolbuffers/protobuf/issues/7427


protoc -I=./ --python_out=./ ./binlog.proto


gogoproto/gogo.proto: File not found.

binlog.proto:3:1: Import "gogoproto/gogo.proto" was not found or had errors.

update:

protoc -I=./ -I=./gogoproto --python_out=./  gogoproto/gogo.proto ./binlog.proto



上一篇:多路麦克风话筒扩展,蓝牙音频接收器
下一篇:go语言结构体列表追加,中如何实现动态添加自定义的结构体到一个集合?

The minute you think of giving up, think of the reason why you held on so long.