Procházet zdrojové kódy

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>
Joe Tsai před 6 roky
rodič
revize
1080a45db5
1 změnil soubory, kde provedl 0 přidání a 38 odebrání
  1. 0 38
      cmd/protoc-gen-go/internal_gengo/main.go

+ 0 - 38
cmd/protoc-gen-go/internal_gengo/main.go

@@ -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) {