go 的 protoc 插件调用逻辑
2016-05-13 16:50
429 查看
要让protoc使用插件,需要做下面事情:
PlacethepluginbinarysomewhereinthePATHandgiveitthename"protoc-gen-NAME"(replacing"NAME"withthenameofyourplugin).
Ifyoutheninvokeprotocwiththeparameter–NAME_out=OUT_DIR(again,replace"NAME"withyourplugin'sname),protocwillinvokeyourplugintogeneratetheoutput,whichwillbeplacedinOUT_DIR.
Placethepluginbinaryanywhere,withanyname,andpassthe–pluginparametertoprotoctodirectittoyourpluginlikeso:
protoc--plugin=protoc-gen-NAME=path/to/mybinary--NAME_out=OUT_DIR
OnWindows,makesuretoincludethe.exesuffix:
protoc--plugin=protoc-gen-NAME=path/to/mybinary.exe--NAME_out=OUT_DIR
参考:https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.compiler.plugin
产生go的grpc代码的插件命令为:
PlacethepluginbinarysomewhereinthePATHandgiveitthename"protoc-gen-NAME"(replacing"NAME"withthenameofyourplugin).
Ifyoutheninvokeprotocwiththeparameter–NAME_out=OUT_DIR(again,replace"NAME"withyourplugin'sname),protocwillinvokeyourplugintogeneratetheoutput,whichwillbeplacedinOUT_DIR.
Placethepluginbinaryanywhere,withanyname,andpassthe–pluginparametertoprotoctodirectittoyourpluginlikeso:
protoc--plugin=protoc-gen-NAME=path/to/mybinary--NAME_out=OUT_DIR
OnWindows,makesuretoincludethe.exesuffix:
protoc--plugin=protoc-gen-NAME=path/to/mybinary.exe--NAME_out=OUT_DIR
参考:
产生go的grpc代码的插件命令为:
protoc--go_out=plugins=grpc,import_path=mypackage:.*.proto[/code][/code]这里通过--NAME_out,就能知道是需要找protoc-gen-NAME插件,即protoc-gen-go插件。[/code]
而--go_out=plugins=grpc则会在https://github.com/golang/protobuf这里找到
https://github.com/golang/protobuf/blob/master/protoc-gen-go/grpc/grpc.go做为插件。
相关文章推荐
- Category在开发中使用的淫技之——改变系统方法
- 最优Django环境配置
- golang中的类型和接口
- E - Gerald's Hexagon
- Mongo命令批量更新某一数组字段的顺序
- download and install Mongo db
- Google 开源了世界上最准确的语言解析器 Parsey McParseface
- 个人godaddy域名备案解决方案
- Going deeper with convolutions:卷积的更深一些
- 思源黑体下载 - Google 联合 Adobe 发布免费开源优雅的设计字体 (简繁中文/日韩文)
- wordpress 访问 gravatar 以及 google map api 慢的解决办法
- django 消息模块 (messages ) 的使用
- go 方法
- mac修改host文件,让你的mac轻松上google
- django 基础入门(二)
- Fusion Tables 图层用于呈现 Google Fusion Tables 中包含的数据
- Django基础(二)—— models
- 多边形glPolygonMode glFrontFace glCullFace glPolygonStipple
- google-hosts
- googleNet