Go proto: 文件未找到

huangapple go评论90阅读模式
英文:

Go proto: File not found

问题

我一直在尝试运行以下命令:

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

出现以下错误:

github.com/x/customValidation/validators.proto: 文件未找到。
test_server/test.proto:5:1: 导入 "github.com/x/customValidation/validators.proto" 未找到或存在错误。

我可以看到 proto 文件位于此位置 -> github.com/x/customValidation/validators.proto,并且在本地保存在 -> pkg\mod\github.com\x\custom!validation@v0.0.0-20210817213416-5eb0b8804c6f

我还尝试了 --proto_path 命令,仍然得到相同的错误,即找不到 proto 文件:

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
英文:

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

答案1

得分: 1

这似乎是路径的问题。路径必须相对于你执行的位置准确,或者是绝对路径。

英文:

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

huangapple
  • 本文由 发表于 2021年8月19日 02:52:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/68837882.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定