Comments (5)
My first recommendation is that you replace ,
with something else in your generator parameters.
Failing that, yes, I recommend that you parse the CodeGeneratorRequest.Parameters
yourself.
(As a distant third, I recommend that you find the protoc
maintainers and get them to add a repeated field to CodeGeneratorRequest
containing the individual parameters.) (I am not actually recommending this.) (It would be nice, though.)
from protobuf.
Thanks for filing this feature request.
To summarize the different alternatives from my point of view:
- We build a parser that supports escaping of the ',' so that values (or even keys) can contain ','.
- We add an overwrite option for users to provide a custom parser. This could be as simple as
func (string) []KeyValuePairs
where KeyValuePairs is just a pair of strings. - Users could encode their parameters with something that doesn't contain ',' (e.g. base64) before passing it to protoc and decode it when their callback is invoked.
Solution 1. requires us to define the exact grammer for escaping and add the implementation (which is 175 lines in the prototype change).
Solution 3. doesn't require any changes but is suboptimal to use and certainly works around a limitation in the protogen package).
Solution 2. requires a very small change to the protogen but adds another public API.
I would like to get @neild feedback on this as well.
from protobuf.
I believe the behavior of separating options with a comma comes from protoc
: If you pass --go_opt=a --go_opt=b
, protoc
passes a CodeGeneratorRequest.parameter
of a,b
. No quoting or escaping, it just joins all --*_opt
params with a comma; see https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/compiler/command_line_interface.cc#L2393.
As such, I think the right thing to do is accept that commas are not valid in option values.
If you do need some different behavior, then you can always modify the CodeGeneratorRequest
before passing it to protogen.Options.New
. (This requires that you use New
rather than Run
, but Run
isn't all that complicated.)
from protobuf.
@neild if I understand correctly, what you are recommending is parsing the CodeGeneratorRequest.Parameters
and quoting/escaping it. Basically, duplicating the protogen.Options.run
logic in our own plugin. Am I getting this right?
from protobuf.
Closing this issue for now. Feel free to reopen if you have further input or questions.
from protobuf.
Related Issues (20)
- Make M option overwrite `option go_package` in the `.proto` file (as opposed to return an error) HOT 5
- related to #1054 and similar "plugin output is unparseable" errors HOT 4
- Random 0xfeff / ZERO WIDTH NO-BREAK SPACE being added to returned string values HOT 3
- custom options doesn't seem to work for protobuf map fields HOT 2
- Can protobuf provide tags for customized message generated fields? HOT 2
- encoding/protojson: unmarshalBytes assumes no padding if byte string length is not divisible by 4 HOT 27
- Service crash caused by encoding HOT 3
- structpb.Struct.MarshalJSON is not consistent HOT 4
- --gofast_out option in protoc discards inline comments from .proto files HOT 1
- How to redefine the json tag? HOT 2
- proto.Equal does not check for nested invalidity HOT 5
- A terrible work-around: HOT 2
- protoreflect x dynamicpb interaction: should descriptors match names or be pointer-identical?
- add proto.IsWellFormed helper function to validate that a message value is well-formed HOT 1
- google.protobuf.Empty as response serializes to not empty response depending on request headers HOT 2
- protocmp: Panic on embed message field comparison HOT 7
- Panic when use enum.String() before main() HOT 2
- Proposal: remove presumably unused purego support
- Why does deserialize []byte("xxxx") into a proto structure work? HOT 2
- proto: Export ErrInvalidUTF8 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protobuf.