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
430 stars 70 forks source link

[IDEA] How to name a template by the name of a message? #157

Closed zachfi closed 4 years ago

zachfi commented 4 years ago

Is your feature request related to a problem? Please describe. I'm looking to generate client helper methods for each protobuf message to access a database.

Describe the solution you'd like To be able to name a template like templates/{{ .MessageName }}.go.tmpl or some such.

Describe alternatives you've considered Copying a template file to the places I need it to be named, for each message type I want to render.

moul commented 4 years ago

👋

This is already implemented, but you need to escape the filename, i.e.: https://github.com/moul/protoc-gen-gotemplate/tree/master/examples/single-package-mode

Tell me if it works for you

zachfi commented 4 years ago

Oh neat! I'll use that, thank you. Just out of curiosity, why does it need it be escaped? But I know nothing of how this actually works.

Also thank you for this rad project. I've been generating all sorts of stuff based on the proto file; ldap database schema, client methods for my rpc, goodies galore.