golang protobuf remove omitempty tag from generated json tags

后端 未结 7 1327
余生分开走
余生分开走 2021-02-04 00:00

I am using google grpc with a json proxy. for some reason i need to remove the omitempty tags from the struct generated in the *.pb.go files.

if i have a pr

7条回答
  •  暖寄归人
    2021-02-04 00:44

    you can copy the encoding/json package to your own folder for example my_json, and modify omitEmpty field to false, and use my_json.Marshal() to encode the struct to json string.

提交回复
热议问题