golang protobuf remove omitempty tag from generated json tags

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

    The Marshaler under the jsonpb package has a EmitDefaults field. Setting this to true, will just ignore the omitempty tag in struct.

    https://godoc.org/github.com/golang/protobuf/jsonpb#JSONPBMarshaler

提交回复
热议问题