golang protobuf remove omitempty tag from generated json tags

后端 未结 7 1293
余生分开走
余生分开走 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:32

    You can try using gogo proto (https://github.com/gogo/protobuf) With the jsontag extension, your proto message would look like

    message Status {
      int32 code = 1 [(gogoproto.jsontag) = "code"];
      string message = 2 [(gogoproto.jsontag) = "message"];
    }
    

    You can also add more tags, if you like.

提交回复
热议问题