Search code examples
goprotocol-buffersproto

Go validation using envoy proxy validator and gogo protobuf


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/[email protected] \
--proto_path=${GOPATH}/pkg/mod/github.com/envoyproxy/[email protected]
--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/[email protected] \
--proto_path=${GOPATH}/pkg/mod/github.com/envoyproxy/[email protected] \
--proto_path=. \
--gogo_out=. \
-—go_out=":./generated" \
—-validate_out="lang=go:./generated" \
--govalidators_out=gogoimport=true:. \
proto/test.proto

I am getting Unknown flag: -?


Solution

  • you missed \ after get-validate and later...

    protoc  \
    --proto_path=${GOPATH}/src \
    --proto_path=${GOPATH}/pkg/mod/github.com/gogo/[email protected] \
    --proto_path=${GOPATH}/pkg/mod/github.com/envoyproxy/[email protected] \
    --proto_path=. \
    --gogo_out=. \
    —-validate_out="lang=go:." \
    --govalidators_out=gogoimport=true:. \
    proto/*.proto