- 有很多种方法,公司级的最好还是修改源码
https://github.com/golang/protobuf/blob/master/protoc-gen-go/generator/generator.go#L2500
tag := fmt.Sprintf(“protobuf:%s json:%q”, g.goTag(message, field, wiretype), jsonName+”,omitempty”)
删除omitempty即可
本文介绍了一种方法来移除Protobuf生成的JSON代码中的omitempty属性。通过修改源码,具体为golang/protobuf项目的generator.go文件第2500行,可以实现这一目的。
https://github.com/golang/protobuf/blob/master/protoc-gen-go/generator/generator.go#L2500
tag := fmt.Sprintf(“protobuf:%s json:%q”, g.goTag(message, field, wiretype), jsonName+”,omitempty”)
删除omitempty即可
9098

被折叠的 条评论
为什么被折叠?
