Protobuf验证器命令在错误的路径中生成文件
我正在尝试包括GRPC的请求验证。我像这样修改了Protobuf命令。 pkg/test/test.proto
包含我的架构。
如果我运行以下命令:
protoc --go_out=. \
--proto_path=${GOPATH}/src \
--proto_path=${GOPATH}/src/github.com/gogo/protobuf/gogoproto/ \
--proto_path=${GOPATH}/src/github.com/mwitkow/go-proto-validators/ \
--proto_path=. \ --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative pkg/test/test.proto --govalidators_out=.
validator.go
未在pkg/test中生成文件,而不是在新文件夹中生成的新文件夹中生成的文件{源相对pkg}/pkg/test /test.proto/validator.go
。
如何在没有文件夹结构的情况下生成验证器
pkg/test
中的文件?
I am trying to include request validation for grpc. I modified the protobuf command like this.pkg/test/test.proto
contains my schema.
If i run the below command :
protoc --go_out=. \
--proto_path=${GOPATH}/src \
--proto_path=${GOPATH}/src/github.com/gogo/protobuf/gogoproto/ \
--proto_path=${GOPATH}/src/github.com/mwitkow/go-proto-validators/ \
--proto_path=. \ --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative pkg/test/test.proto --govalidators_out=.
The validator.go
file generated file is not generated inside pkg/test instead it is getting generated inside a new folder created {source relative pkg}/pkg/test/test.proto/validator.go
.
How to generate validator.go
file without the folder structure in pkg/test
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
分析
看起来像
*。验证器.pb.go
文件是在错误的目录中生成的。使用
pkg/test/test.proto
文件>以下内容:生成文件系统内容:
解决方案
添加
- govalidators_opt = paths = paths = source_relative
命令行参数。请注意参数名称:
完整的命令行:
产生的文件系统内容:
其他引用
Analysis
It looks like the
*.validator.pb.go
files are generated in the wrong directory.Using the
pkg/test/test.proto
file with the following content:Produced the file system contents:
Solution
Add the
--govalidators_opt=paths=source_relative
command line argument.Please, note the parameter name:
The complete command line:
Produced the file system contents:
Additional references