Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gen and protobuf #99

Open
kanekv opened this issue May 9, 2016 · 5 comments
Open

gen and protobuf #99

kanekv opened this issue May 9, 2016 · 5 comments

Comments

@kanekv
Copy link

kanekv commented May 9, 2016

I want to use gen on structures defined by protobuf. But protobuf files are themselves generated and it is not recommended to edit them. Is there any way to get around this?

@clipperhouse
Copy link
Owner

Hmm, sounds like not a great idea. gen is for your types -- I assume that the generated proto files represent an external package's types?

@kanekv
Copy link
Author

kanekv commented May 10, 2016

Why? Protobuf could be used to exchange data between my own services. They are my own types, just defined differently.

@clipperhouse
Copy link
Owner

Fair, though I don't have a good suggestion off the top of my head. Show me some sample code?

@pavelsmejkal
Copy link

Well there are not many things to show. Protobuf it self generates some interfaces for example.

type ChannelStoreClient interface {
Ping(ctx context.Context, in _Client, opts ...grpc.CallOption) (_Response, error)
....
}

One option would be to have a possibility to add those custom types to "gen" explicitly by command line argument for example.

gen -type 'ChannelStoreClient slice:"Where,Count,GroupBy[string]"'

or support comments like this
// +gen slice:"Where,Count,GroupBy[string]"
// +type ChannelStoreClient

@joeblew99
Copy link

@Kane-Sendgrid
@clipperhouse

This might help: https://github.com/Softwee/Anakin
Anakin takes a GRPC and via AST allows me to get in the middle of it to control exactly what gets code generated. I plan to use it for a bigger code gen project.

clipperhouse/gen can then be used to produce types with extra functionality i need.

SO you are code generating code, and that produced code is used for another coe gen pass.
I knwo the team at goa have written about this and have a multi.stage code generator too, which might be worth studying. i plan to look at it also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants