-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Option to tell protoc to remove omitempty
field from json tags when generating .go files
#1560
Comments
The JSON tags are considered a deprecated feature of protobuf generation, as one should be using the |
What caveats is there? protojson has a lot unexpected behaviour i prefer avoid using it replacing with JSONBuiltin. The only trouble i faced - hardcoded |
The caveats that it cannot correctly implement the proto3 JSON mapping standard. |
Problem
When I generate
.pb.go
files usingprotoc
, its generating structs with json tags where there areomitempty
option in each of the fields:Proto3:
Generated go struct:
Solutions
Option to tell protoc compiler to not generate structs with
omitempty
json tags (For example some arg likeprotoc --json-emitall
)Protobuf to support json-tag related options:
For example, on the top of the .proto file:
Or, support for some per message option like:
Desired Result
So that I can get:
The text was updated successfully, but these errors were encountered: