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)
- Support for optional fields HOT 2
- Latest version of google.golang.org/protobuf (v1.33.0) is no longer compatible with the latest version of github.com/golang/protobuf (v1.5.3) HOT 7
- Add option to JSON marshal / unmarshal: StripEnumPrefix / AddEnumPrefix HOT 10
- How to properly define protobuf `oneof` fields? HOT 2
- How can I import a pre-compiled proto from another package? HOT 4
- protodesc: feature "message_encoding" (in Protobuf editions) triggers proto2 group validation checks HOT 11
- timestamppb.AsTime is incorrectly implemented for nil/zero values HOT 2
- missing replace in go.mod HOT 1
- protojson: fail to unmarshal JSON with reserved fields HOT 19
- go_features.proto has incorrect package and error-prone file path HOT 5
- Tracking issue: Fully Lazy Extension decoding HOT 4
- feature: Generate test client / `bufconn` constructors HOT 4
- v1.33.0 breaks bazel build HOT 14
- Reflection: protopath parsing and path+message access HOT 7
- Proposal: Set go.mod Go language version to oldest supported Go version (1.21 currently) HOT 8
- Proposal: Add `Override` mode to `proto.Merge` HOT 2
- editions: maps are incorrectly serialized if file has default message encoding of DELIMITED HOT 7
- protodesc: too strict about proto3 field names when creating descriptors from FileDescriptorProto
- undefined: descriptorpb.Default_FileOptions_PhpGenericServices HOT 2
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.