golang / protobuf

Go support for Google's protocol buffers
BSD 3-Clause "New" or "Revised" License
9.74k stars 1.58k forks source link

Flexible generation of xxx.pb.go files #1490

Closed PumpkinSeed closed 2 years ago

PumpkinSeed commented 2 years ago

Is your feature request related to a problem? Please describe. Currently the output of the file generation contains a huge amount of methods/fields what we don't need in our use-case.

Describe the solution you'd like Some kind of flexibility what actually we want to generate or what should be in the output. There is an example commit about my thoughts. This doesn't mean that I propose to use env vars, but something similar mechanism to skip certain parts of the generation.

Additional context We don't use grpc we only want to generate our types package by using protobuf.

puellanivis commented 2 years ago

We’ve discussed this matter before recently.

It seems that what you want here is just a simple type definition language, but that’s not what protobuf’s primary goals are. Protobuf is at its heart a polylingual interchange format, and adding knobs and dials to disable functionality runs contrary to the goals and purpose of the package.

PumpkinSeed commented 2 years ago

Yes, you are correct, but I want to keep using protobuf, because anytime we change to grpc I just regenerate the code without the restrictions and I'm on the right path.

puellanivis commented 2 years ago

I’m not saying that you need to switch. I will let it be well known that I have used Protobuf for data type codification as well, and I still will. But I also recognize that this is not protobuf’s raison d’être, and so there’s going to be some other stuff put in at the same time because the marshaling and everything is a central and fundamental feature of this particular tool.

PumpkinSeed commented 2 years ago

Make sense, otherwise I want to aim my fork to specialize for types generation. Because currently no proper tool on the market which generate types on a flexible way. Thanks for the answer.