0

I have been trying to run below command

protoc   -I ./interfaces/  -I ${GOPATH}/pkg/mod/github.com/envoyproxy/protoc-gen-validate@v0.1.0 -I ${GOPATH}/pkg/mod/github.com/gogo/protobuf@v1.3.2 -I ${GOPATH}pkg/mod/github.com/x --gogo_out=. --go_out="plugins=grpc:./generated"   --validate_out="lang=go:./generated" ./interfaces/test_server/*.proto

Getting below error

github.com/x/customValidation/validators.proto: File not found. test_server/test.proto:5:1: Import "github.com/x/customValidation/validators.proto" was not found or had errors.

I can see the proto file is in this location -> github.com/x/customValidation/validators.proto and locally it got saved at -> pkg\mod\github.com\x\custom!validation@v0.0.0-20210817213416-5eb0b8804c6f

I also tried with --proto_path command still getting same error that proto file is not found

protoc  \
--proto_path=${GOPATH}/src \
--proto_path=${GOPATH}/pkg/mod/github.com/gogo/protobuf@v1.3.2 \
--proto_path=${GOPATH}/pkg/mod/github.com/envoyproxy/protoc-gen-validate@v0.1.0 \
--proto_path=${GOPATH}pkg/mod/github.com/x \
--proto_path=. --gogo_out=. --govalidators_out=gogoimport=true:. --go_out="plugins=grpc:./generated" --validate_out="lang=go:./generated" ./interfaces/test_server/*.proto
Maana
  • 640
  • 3
  • 9
  • 22
  • 1
    The protobufs to be compiled (i.e. `./interfaces/test_server/*.proto`) must appear in one of the `proto_path`s too. I think you may need to use absolute paths too i.e. `${PWD}/interfaces` instead of `./interfaces`. So, you'll want `... --proto_path=${PWD}/interfaces/test_server ... ${PWD}/interfaces/test_server/*.proto` – DazWilkin Aug 18 '21 at 19:11
  • Does this answer your question? [protoc: Go package has inconsistent package names](https://stackoverflow.com/questions/64443549/protoc-go-package-has-inconsistent-package-names) – ttrasn Aug 23 '21 at 06:17

1 Answers1

1

This feels like an issue with paths. The path must be accurate relative to where you are executing or an absolute path.

ATS
  • 174
  • 1
  • 10