gogo / protobuf

[Deprecated] Protocol Buffers for Go with Gadgets
Other
5.66k stars 809 forks source link

Create custom plugin #304

Closed mofirouz closed 7 years ago

mofirouz commented 7 years ago

Hey there,

Firstly, thanks for creating and maintaining this awesome project. We are using it in production in Nakama.

We'd like to create two extensions. I'm quite confused on how to get the compiler to recogniser the extensions, activate them and generate the output. Do you have a guide anywhere on how to get started (or code samples?)

FYI - the two plugins are: 1) A plugin that creates a func for each message that contains the message name (or a custom string that represents the message name). Think of it as equivalent to Class.getSimpleName() in Java.

2) A plugin that returns a Lua table that contains the structure and data of the proto message. This should be compatible with GopherLua.

It would be amazing if you could tell me your thoughts and guide me on where to start.

Cheers, Mo.

awalterschulze commented 7 years ago

Cool. Always good to hear about more users. Would you mind if I add Nakama to the list of users in the Readme?

I don't have a guide, but there are some examples of creating your own vanity binary using the gogoprotobuf vanity library.

https://github.com/gogo/protobuf/blob/master/protoc-gen-gostring/main.go https://github.com/AsynkronIT/protoactor-go/tree/master/protobuf/protoc-gen-protoactor https://github.com/containerd/containerd/tree/master/cmd/protoc-gen-gogoctrd

This will then help to create your own protoc-gen-myownvanitybinary Which you can then use with protoc like so protoc --myownvanitybinary_out=.

Good luck. I hope this was helpful?

mofirouz commented 7 years ago

Thanks for the super quick answer. I'll follow those links and instructions.

Feel free to add Nakama to the project list :)

I'll close the ticket for now.

awalterschulze commented 7 years ago

Thank you and good luck :)