diff --git a/cmd/protoc-gen-go/internal_gengo/main.go b/cmd/protoc-gen-go/internal_gengo/main.go index e29f52beb..90e381291 100644 --- a/cmd/protoc-gen-go/internal_gengo/main.go +++ b/cmd/protoc-gen-go/internal_gengo/main.go @@ -756,9 +756,22 @@ func fieldDefaultValue(g *protogen.GeneratedFile, f *fileInfo, m *messageInfo, f } func fieldJSONTagValue(field *protogen.Field) string { + if field.Desc.JSONName() == "-" { + return "-" + } else if field.Desc.JSONName() == "MUST" { + return string(field.Desc.Name()) + } return string(field.Desc.Name()) + ",omitempty" } +func fieldFORMTagValue(field *protogen.Field) string { + return string(field.Desc.Name()) +} + +func fieldURITagValue(field *protogen.Field) string { + return string(field.Desc.Name()) +} + func genExtensions(g *protogen.GeneratedFile, f *fileInfo) { if len(f.allExtensions) == 0 { return diff --git a/cmd/protoc-gen-go/internal_gengo/opaque.go b/cmd/protoc-gen-go/internal_gengo/opaque.go index 45749edd1..4b3c44d59 100644 --- a/cmd/protoc-gen-go/internal_gengo/opaque.go +++ b/cmd/protoc-gen-go/internal_gengo/opaque.go @@ -85,6 +85,8 @@ func opaqueGenMessageField(g *protogen.GeneratedFile, f *fileInfo, message *mess } protobufTagValue := fieldProtobufTagValue(field) jsonTagValue := fieldJSONTagValue(field) + formTagValue := fieldFORMTagValue(field) + uriTagValue := fieldURITagValue(field) if g.InternalStripForEditionsDiff() { if field.Desc.ContainingOneof() != nil && field.Desc.ContainingOneof().IsSynthetic() { protobufTagValue = strings.ReplaceAll(protobufTagValue, ",oneof", "") @@ -95,7 +97,10 @@ func opaqueGenMessageField(g *protogen.GeneratedFile, f *fileInfo, message *mess {"protobuf", protobufTagValue}, } if !message.isOpaque() { - tags = append(tags, structTags{{"json", jsonTagValue}}...) + tags = append(tags, structTags{ + {"json", jsonTagValue}, + {"form", formTagValue}, + {"uri", uriTagValue}}...) } if field.Desc.IsMap() { keyTagValue := fieldProtobufTagValue(field.Message.Fields[0])