moul / protoc-gen-gotemplate

:open_file_folder: generic protocol generator based on golang's text/template (grpc/protobuf)
https://manfred.life/protoc-gen-gotemplate
MIT License
438 stars 70 forks source link

One output file from multiple services in multiple files. #149

Open damouse opened 4 years ago

damouse commented 4 years ago

First of all-- fantastic library, thanks for all the work!

For my use case I need one output file, but I'd like to use multiple proto files each with their own service definitions. This is because the output will automatically be ingested by other code, but the input is going to be managed by developers, and having multiple files on that end will help with organization.

My templates have some static code at the top that should be repeated once for the entire file, but when I run with multiple service definitions in one or more proto files, the whole template is repeated, once for each service. This leads to repeated imports and package declarations in the output. Is there any way to iterate over services or files in the template, so I can control what is being repeated? I don't think I saw multiple services in any of the examples provided, is this supported?