cmd/protoc-gen-go: remove XXX_WellKnownType

Change-Id: I57821f6d9e4950707442b5713734a316727ae96a
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/186897
Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
Joe Tsai 2019-07-19 01:17:31 -07:00
parent 9429392195
commit 1080a45db5

View File

@ -48,10 +48,6 @@ const (
// ExtensionRangeArray method for messages that support extensions.
generateExtensionRangeMethods = true
// generateWKTMarkerMethods specifies whether to generate
// XXX_WellKnownType methods on well-known types.
generateWKTMarkerMethods = false
// generateMessageStateFields specifies whether to generate an unexported
// protoimpl.MessageState as the first field.
generateMessageStateFields = true
@ -98,28 +94,6 @@ type goImportPath interface {
Ident(string) protogen.GoIdent
}
// Names of messages and enums for which we will generate XXX_WellKnownType methods.
var wellKnownTypes = map[protoreflect.FullName]bool{
"google.protobuf.Any": true,
"google.protobuf.Duration": true,
"google.protobuf.Empty": true,
"google.protobuf.Struct": true,
"google.protobuf.Timestamp": true,
"google.protobuf.BoolValue": true,
"google.protobuf.BytesValue": true,
"google.protobuf.DoubleValue": true,
"google.protobuf.FloatValue": true,
"google.protobuf.Int32Value": true,
"google.protobuf.Int64Value": true,
"google.protobuf.ListValue": true,
"google.protobuf.NullValue": true,
"google.protobuf.StringValue": true,
"google.protobuf.UInt32Value": true,
"google.protobuf.UInt64Value": true,
"google.protobuf.Value": true,
}
type fileInfo struct {
*protogen.File
@ -403,12 +377,6 @@ func genEnum(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, enum
g.P("}")
g.P()
}
// XXX_WellKnownType method.
if generateWKTMarkerMethods && wellKnownTypes[enum.Desc.FullName()] {
g.P("func (", enum.GoIdent, `) XXX_WellKnownType() string { return "`, enum.Desc.Name(), `" }`)
g.P()
}
}
// enumLegacyName returns the name used by the v1 proto package.
@ -666,12 +634,6 @@ func genMessageBaseMethods(gen *protogen.Plugin, g *protogen.GeneratedFile, f *f
g.P("}")
g.P()
}
// XXX_WellKnownType method.
if generateWKTMarkerMethods && wellKnownTypes[message.Desc.FullName()] {
g.P("func (*", message.GoIdent, `) XXX_WellKnownType() string { return "`, message.Desc.Name(), `" }`)
g.P()
}
}
func genMessageGetterMethods(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, message *protogen.Message) {