cmd/protoc-gen-go: disable generation of XXX_WellKnownType
The logic for this will be removed entirely in a future CL.
Change-Id: I3a20fb2a207fc5bedc550b3f6deeab7f63eaa2c4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/185243
Reviewed-by: Herbie Ong <[email protected]>
diff --git a/cmd/protoc-gen-go/internal_gengo/main.go b/cmd/protoc-gen-go/internal_gengo/main.go
index 7a2fee0..47c47aa 100644
--- a/cmd/protoc-gen-go/internal_gengo/main.go
+++ b/cmd/protoc-gen-go/internal_gengo/main.go
@@ -40,6 +40,10 @@
// XXX_OneofWrappers methods on messages with oneofs.
generateOneofWrapperMethods = false
+ // generateWKTMarkerMethods specifes whether to generate
+ // XXX_WellKnownType methods on well-known types.
+ generateWKTMarkerMethods = false
+
// generateNoUnkeyedLiteralFields specifies whether to generate
// the XXX_NoUnkeyedLiteral field.
generateNoUnkeyedLiteralFields = false
@@ -742,10 +746,8 @@
return "// Deprecated: Do not use."
}
-// TODO: Remove this. This was added to aid protojson, but protojson does this work
-// through the use of protobuf reflection now.
func genWellKnownType(g *protogen.GeneratedFile, ptr string, ident protogen.GoIdent, desc protoreflect.Descriptor) {
- if wellKnownTypes[desc.FullName()] {
+ if generateWKTMarkerMethods && wellKnownTypes[desc.FullName()] {
g.P("func (", ptr, ident, `) XXX_WellKnownType() string { return "`, desc.Name(), `" }`)
g.P()
}
diff --git a/types/known/anypb/any.pb.go b/types/known/anypb/any.pb.go
index 71e687d..41a3e9a 100644
--- a/types/known/anypb/any.pb.go
+++ b/types/known/anypb/any.pb.go
@@ -156,8 +156,6 @@
return file_google_protobuf_any_proto_rawDescGZIP(), []int{0}
}
-func (*Any) XXX_WellKnownType() string { return "Any" }
-
func (x *Any) GetTypeUrl() string {
if x != nil {
return x.TypeUrl
diff --git a/types/known/durationpb/duration.pb.go b/types/known/durationpb/duration.pb.go
index 3d7dac7..20043ee 100644
--- a/types/known/durationpb/duration.pb.go
+++ b/types/known/durationpb/duration.pb.go
@@ -116,8 +116,6 @@
return file_google_protobuf_duration_proto_rawDescGZIP(), []int{0}
}
-func (*Duration) XXX_WellKnownType() string { return "Duration" }
-
func (x *Duration) GetSeconds() int64 {
if x != nil {
return x.Seconds
diff --git a/types/known/emptypb/empty.pb.go b/types/known/emptypb/empty.pb.go
index 6b3935d..a6aabb7 100644
--- a/types/known/emptypb/empty.pb.go
+++ b/types/known/emptypb/empty.pb.go
@@ -54,8 +54,6 @@
return file_google_protobuf_empty_proto_rawDescGZIP(), []int{0}
}
-func (*Empty) XXX_WellKnownType() string { return "Empty" }
-
var File_google_protobuf_empty_proto protoreflect.FileDescriptor
var file_google_protobuf_empty_proto_rawDesc = []byte{
diff --git a/types/known/structpb/struct.pb.go b/types/known/structpb/struct.pb.go
index 9b3efff..84a3434 100644
--- a/types/known/structpb/struct.pb.go
+++ b/types/known/structpb/struct.pb.go
@@ -60,8 +60,6 @@
return file_google_protobuf_struct_proto_rawDescGZIP(), []int{0}
}
-func (NullValue) XXX_WellKnownType() string { return "NullValue" }
-
// `Struct` represents a structured data value, consisting of fields
// which map to dynamically typed values. In some languages, `Struct`
// might be supported by a native representation. For example, in
@@ -100,8 +98,6 @@
return file_google_protobuf_struct_proto_rawDescGZIP(), []int{0}
}
-func (*Struct) XXX_WellKnownType() string { return "Struct" }
-
func (x *Struct) GetFields() map[string]*Value {
if x != nil {
return x.Fields
@@ -159,8 +155,6 @@
return file_google_protobuf_struct_proto_rawDescGZIP(), []int{1}
}
-func (*Value) XXX_WellKnownType() string { return "Value" }
-
func (m *Value) GetKind() isValue_Kind {
if m != nil {
return m.Kind
@@ -283,8 +277,6 @@
return file_google_protobuf_struct_proto_rawDescGZIP(), []int{2}
}
-func (*ListValue) XXX_WellKnownType() string { return "ListValue" }
-
func (x *ListValue) GetValues() []*Value {
if x != nil {
return x.Values
diff --git a/types/known/timestamppb/timestamp.pb.go b/types/known/timestamppb/timestamp.pb.go
index 2639d5c..62f6f6c 100644
--- a/types/known/timestamppb/timestamp.pb.go
+++ b/types/known/timestamppb/timestamp.pb.go
@@ -136,8 +136,6 @@
return file_google_protobuf_timestamp_proto_rawDescGZIP(), []int{0}
}
-func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" }
-
func (x *Timestamp) GetSeconds() int64 {
if x != nil {
return x.Seconds
diff --git a/types/known/wrapperspb/wrappers.pb.go b/types/known/wrapperspb/wrappers.pb.go
index 2df1119..20ca470 100644
--- a/types/known/wrapperspb/wrappers.pb.go
+++ b/types/known/wrapperspb/wrappers.pb.go
@@ -50,8 +50,6 @@
return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{0}
}
-func (*DoubleValue) XXX_WellKnownType() string { return "DoubleValue" }
-
func (x *DoubleValue) GetValue() float64 {
if x != nil {
return x.Value
@@ -92,8 +90,6 @@
return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{1}
}
-func (*FloatValue) XXX_WellKnownType() string { return "FloatValue" }
-
func (x *FloatValue) GetValue() float32 {
if x != nil {
return x.Value
@@ -134,8 +130,6 @@
return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{2}
}
-func (*Int64Value) XXX_WellKnownType() string { return "Int64Value" }
-
func (x *Int64Value) GetValue() int64 {
if x != nil {
return x.Value
@@ -176,8 +170,6 @@
return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{3}
}
-func (*UInt64Value) XXX_WellKnownType() string { return "UInt64Value" }
-
func (x *UInt64Value) GetValue() uint64 {
if x != nil {
return x.Value
@@ -218,8 +210,6 @@
return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{4}
}
-func (*Int32Value) XXX_WellKnownType() string { return "Int32Value" }
-
func (x *Int32Value) GetValue() int32 {
if x != nil {
return x.Value
@@ -260,8 +250,6 @@
return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{5}
}
-func (*UInt32Value) XXX_WellKnownType() string { return "UInt32Value" }
-
func (x *UInt32Value) GetValue() uint32 {
if x != nil {
return x.Value
@@ -302,8 +290,6 @@
return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{6}
}
-func (*BoolValue) XXX_WellKnownType() string { return "BoolValue" }
-
func (x *BoolValue) GetValue() bool {
if x != nil {
return x.Value
@@ -344,8 +330,6 @@
return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{7}
}
-func (*StringValue) XXX_WellKnownType() string { return "StringValue" }
-
func (x *StringValue) GetValue() string {
if x != nil {
return x.Value
@@ -386,8 +370,6 @@
return file_google_protobuf_wrappers_proto_rawDescGZIP(), []int{8}
}
-func (*BytesValue) XXX_WellKnownType() string { return "BytesValue" }
-
func (x *BytesValue) GetValue() []byte {
if x != nil {
return x.Value