Hey, Zellyn,
I don't think it's possible for protoc-gen-go to do what you're asking.
IIRC, protoc itself always populates this field in the field descriptor. So
I don't think a plugin can actually make this distinction -- at least not
without a change to protoc. And the downside to a change to protoc is that
it would require all code-gen plugins (and/or runtime libraries that
implement the JSON encoding) to have redundant logic for computing the
canonical JSON name from the proto name.

----
*Josh Humphries*
[email protected]


On Wed, Jan 16, 2019 at 10:10 AM Zellyn <[email protected]> wrote:

> A quick followup: a reason that including a json name for every field in
> the descriptor is bad: it makes it impossible to tell whether an explicit
> json_name was specified or not. So it would be impossible to give jsonpb a
> mode (which it needs, imho) where it uses the protobuf field names as-is,
> unless an explicit json_name was specified.
>
> Or am I understanding it wrong?
>
> Zellyn
>
>
> On Tuesday, January 15, 2019 at 12:47:31 PM UTC-5, Zellyn wrote:
>>
>> Hey folks,
>>
>> We're trying to update the version of protoc we use for compiling our Go
>> protobufs. It appears that at some point between 3.0.0 and 3.6.0, protoc
>> started populating the `json_name` field option for *every* field,
>> whether the option was specified or not. Is that expected? If so, could
>> anyone help me track down the commit that did it?
>>
>> Thanks,
>>
>> Zellyn
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to