go下载插件到bin目录下, 使用go env 可以查看
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
可以直接使用了,输出proto对应文件
# 格式: protoc --go_out 目标路径 文件路径
protoc --go_out ./ ./heart_beat.proto
如果发现提示:
File does not reside within any path specified using --proto_path (or -I). You must specify a --proto_path which encompasses this file. Note that the proto_path must be an exact prefix of the .proto file names – protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it’s harder than you think).
请这样使用:
先进入proto文件对应的文件夹
protoc [proto文件名] --go_out [生成的路径]
最后
以上就是自觉万宝路最近收集整理的关于go语言生成.proto生成go文件的全部内容,更多相关go语言生成内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复