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

Add stringMethodOptionsExtension #93

Closed weitzj closed 6 years ago

weitzj commented 6 years ago

This helper function can be used on service methods to read options, which extend method options by a string.

e.g.

It is possible to read "Some string" for a custom

my_method_option.bar message option extension.

See:

https://developers.google.com/protocol-buffers/docs/proto#customoptions

on how to define a custom extension and referencing is by a fieldID.

service MyService {

  rpc MyMethod(RequestType) returns(ResponseType) {
    option (my_method_option.bar) = "Some string";
  }
}

If my_method_option.bar was defined for fieldID: 50000 one can reference it using protoc-gen-template like:

{{- stringMethodOptionsExtension 50000 .method }}
weitzj commented 6 years ago

@moul

weitzj commented 6 years ago

Hi. Is there anything I can help you with to get this merged?

moul commented 6 years ago

Hi @weitzj sorry for the delay and thank you for your PR :)

weitzj commented 6 years ago

Thank you. This is a great tool.