Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -378,6 +378,7 @@ func genMessageField(g *protogen.GeneratedFile, f *fileInfo, m *messageInfo, fie

tags := structTags{
{"protobuf_oneof", string(oneof.Desc.Name())},
{"json", string(oneof.Desc.JSONName()) + ",omitempty"},
}
if m.isTracked {
tags = append(tags, gotrackTags...)
Expand Down Expand Up @@ -812,6 +813,7 @@ func genMessageOneofWrapperTypes(g *protogen.GeneratedFile, f *fileInfo, m *mess
goType, _ := fieldGoType(g, f, field)
tags := structTags{
{"protobuf", fieldProtobufTagValue(field)},
{"json", string(field.Desc.JSONName())},
}
if m.isTracked {
tags = append(tags, gotrackTags...)
Expand Down
4 changes: 2 additions & 2 deletions cmd/protoc-gen-go/testdata/comments/comments.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 23 additions & 23 deletions cmd/protoc-gen-go/testdata/proto2/fields.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/protoc-gen-go/testdata/retention/retention.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/descfmt/desc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func TestDescriptorAccessors(t *testing.T) {
"Syntax": true,
"Name": true,
"FullName": true,
"JSONName": true,
"IsPlaceholder": true,
"Options": true,
"ProtoInternal": true,
Expand Down
1 change: 1 addition & 0 deletions internal/filedesc/desc.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ func (od *Oneof) Options() protoreflect.ProtoMessage {
func (od *Oneof) Fields() protoreflect.FieldDescriptors { return &od.L1.Fields }
func (od *Oneof) Format(s fmt.State, r rune) { descfmt.FormatDesc(s, r, od) }
func (od *Oneof) ProtoType(protoreflect.OneofDescriptor) {}
func (od *Oneof) JSONName() string { return strs.JSONCamelCase(string(od.Name())) }

type (
Extension struct {
Expand Down
Loading