fix
This commit is contained in:
parent
91a5eb75b8
commit
3e2a6822b6
|
@ -0,0 +1,13 @@
|
|||
# protoc-gen-coco
|
||||
|
||||
## install
|
||||
|
||||
```shell
|
||||
go install gitter.top/coco/protoc-gen-coco@latest
|
||||
```
|
||||
|
||||
## usage
|
||||
|
||||
```shell
|
||||
protoc example.proto --coco_out=. --go_out=.
|
||||
```
|
|
@ -7,6 +7,9 @@ option go_package = "./;main";
|
|||
// @route_group: true
|
||||
// @base_url: /api/v1
|
||||
service ExampleService { // tail
|
||||
// @author: xuthus
|
||||
// @desc: test rpc
|
||||
// @method: GET
|
||||
rpc ExampleCall1(ExampleMessage1) returns(ReturnType) {}
|
||||
rpc ExampleCall2(ExampleMessage2) returns(ReturnType) {}
|
||||
}
|
9
main.go
9
main.go
|
@ -13,12 +13,17 @@ func (c *Coco) Generate(plugin *protogen.Plugin) error {
|
|||
if len(plugin.Files) == 0 {
|
||||
return nil
|
||||
}
|
||||
c.generateRouter(plugin)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Coco) generateRouter(plugin *protogen.Plugin) {
|
||||
for _, pbFile := range plugin.Files {
|
||||
// service empty
|
||||
if len(pbFile.Services) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// write file header
|
||||
filename := fmt.Sprintf("autogen_router_%s.go", pbFile.GeneratedFilenamePrefix)
|
||||
g := plugin.NewGeneratedFile(filename, pbFile.GoImportPath)
|
||||
|
@ -47,9 +52,7 @@ func (c *Coco) Generate(plugin *protogen.Plugin) error {
|
|||
g.P(values)
|
||||
g.P()
|
||||
}
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
Loading…
Reference in New Issue