Skip to content

Commit

Permalink
feat: add proper json tag in oneof
Browse files Browse the repository at this point in the history
  • Loading branch information
Misfits09 committed Jan 24, 2025
1 parent 4cf3752 commit a2b9b3b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/protoc-gen-go/internal_gengo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ func genMessageField(g *protogen.GeneratedFile, f *fileInfo, m *messageInfo, fie
if m.isTracked {
tags = append(tags, gotrackTags...)
}
tags = append(tags, [2]string{"json", string(oneof.Desc.Name()) + ",omitempty"})

g.Annotate(m.GoIdent.GoName+"."+oneof.GoName, oneof.Location)
leadingComments := oneof.Comments.Leading
Expand Down Expand Up @@ -886,6 +887,7 @@ func genMessageOneofWrapperTypes(g *protogen.GeneratedFile, f *fileInfo, m *mess
goType, _ := fieldGoType(g, f, field)
tags := structTags{
{"protobuf", fieldProtobufTagValue(field)},
{"json", fieldJSONTagValue(field)},
}
if m.isTracked {
tags = append(tags, gotrackTags...)
Expand Down

0 comments on commit a2b9b3b

Please sign in to comment.