英文:
Go validation using envoy proxy validator and gogo protobuf
问题
我正在尝试编写一个插件来生成验证Go文件。该插件使用https://github.com/mwitkow/go-proto-validators和envoy代理验证器https://github.com/envoyproxy/protoc-gen-validate。以下是我的命令:
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=.
--gogo_out=.
—-validate_out=“lang=go:.\”
--govalidators_out=gogoimport=true:.
proto/*.proto
当我运行上述命令时,我遇到以下错误。有没有专家能提供解决方法?感谢您的帮助。
zsh: command not found: --proto_path=.
zsh: command not found: --govalidators_out=gogoimport=true:.
在添加缺少的“/”之后:
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=.
--gogo_out=.
-—go_out=":./generated"
—-validate_out="lang=go:./generated"
--govalidators_out=gogoimport=true:.
proto/test.proto
我得到了**未知标志:-?**的错误提示。
英文:
I am trying write plugin to generate validate go files. Which uses https://github.com/mwitkow/go-proto-validators and envoy proxy validator https://github.com/envoyproxy/protoc-gen-validate. Below is my command
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=. \
--gogo_out=. \
—-validate_out=“lang=go:.\”
--govalidators_out=gogoimport=true:. \
proto/*.proto
when I run above command I am getting below error? any suggestion expert on how to resolve this. Appreciate your help.
zsh: command not found: --proto_path=.
zsh: command not found: --govalidators_out=gogoimport=true:.
After adding the missing "/"
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=. \
--gogo_out=. \
-—go_out=":./generated" \
—-validate_out="lang=go:./generated" \
--govalidators_out=gogoimport=true:. \
proto/test.proto
I am getting Unknown flag: -?
答案1
得分: 2
你在get-validate后面漏掉了\
...
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=. \
--gogo_out=. \
—-validate_out="lang=go:." \
--govalidators_out=gogoimport=true:. \
proto/*.proto
英文:
you missed \
after get-validate and later...
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=. \
--gogo_out=. \
—-validate_out="lang=go:." \
--govalidators_out=gogoimport=true:. \
proto/*.proto
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论