protoc --gogofaster_out=. image.proto
I get this error message
/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.
The file is definitely there. I can reach it from the reported path in the error.
My proto file looks like this:
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;
}
I have a Makefile
in the dir where the proto file is. Looks like this:
regenerate:
--proto_path=../../github.com/gogo/protobuf/gogoproto:../../github.com/gogo/protobuf/protobuf/google/protobuf:. --gogofaster_out=. *.proto
What can I do to resolve the path error?
As in this issue, you could try and import only the relative path:
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
Make sure that GOPATH
is set to /home/abc
first.
I mention protobuf PR 241, where the makefile defines the PATH to use:
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
The OP mention this thread, which points out:
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
.