go get github.com/wangxudong123/switcher
//@switcher protoGoSrc [github.com/wangxudong123/switcher/example/proto]
//@switcher out ./example/belong.go
syntax = "proto3";
package user;
//@switcher struct HelloWorldDto
message HelloWorld {
string field1 = 1;
string field2 = 2;
}
在该项目的根路径执行命令
switcher make
生成文件在 ./example/belong.go
对以上注解解释
- struct 转换后的结构体名称
- out 输出到文件路径(当前项目根路径的相对路径)
- protoGoSrc 当前
.proto
文件执行protoc生成的go代码包路径(需要拿到这个路径在生成的代码中导入这个包)
- 不支持
enum
- 不支持
reserved
- 不支持 类型嵌套
- 不支持 类型引用(下个迭代支持)