cmd/protoc-gen-go: rely on protoimpl for basic helpers
The EnumName, UnmarshalJSONEnum, and CompressGZIP helpers currently live
in v1 protoapi, which would cause all generated messages to depend on v1.
In an effort to break the dependency of v2 on v1, we move these helper
functions to v2 (and re-written to take advantage of protobuf reflection).
These helpers are unfortunate, but we cannot eliminate the functionality
that they implement since they are exposed in the publicly generated API.
Since EnumName does not rely on the enum maps, it removes another dependency
on those variables. Eventually, we can get to the point where these variables
(though declared) are not linked into the binary if the user does not use them.
Also, we rely on the v1 proto package for registration instead of v1 protoapi.
This may re-introduce a cyclic dependency on descriptor proto again in the
future, but the better approach is to just start registering with v2.
Change-Id: Id755585a7a1df14e4a6a2dfa650df221a3c153fb
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/167921
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
index adbde5a..958b1d8 100644
--- a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
@@ -5,18 +5,11 @@
import (
proto "github.com/golang/protobuf/proto"
- protoapi "github.com/golang/protobuf/protoapi"
protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
reflect "reflect"
)
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
-
// EnumType1 comment.
type EnumType1 int32
@@ -34,35 +27,37 @@
return protoreflect.EnumNumber(e)
}
+// Deprecated: Use EnumType1.Type.Values instead.
var EnumType1_name = map[int32]string{
1: "ONE",
2: "TWO",
}
+// Deprecated: Use EnumType1.Type.Values instead.
var EnumType1_value = map[string]int32{
"ONE": 1,
"TWO": 2,
}
func (x EnumType1) Enum() *EnumType1 {
- p := new(EnumType1)
- *p = x
- return p
+ return &x
}
func (x EnumType1) String() string {
- return proto.EnumName(EnumType1_name, int32(x))
+ return protoimpl.X.EnumStringOf(x.Type(), protoreflect.EnumNumber(x))
}
-func (x *EnumType1) UnmarshalJSON(data []byte) error {
- value, err := proto.UnmarshalJSONEnum(EnumType1_value, data, "EnumType1")
+// Deprecated: Do not use.
+func (x *EnumType1) UnmarshalJSON(b []byte) error {
+ num, err := protoimpl.X.UnmarshalJSONEnum(x.Type(), b)
if err != nil {
return err
}
- *x = EnumType1(value)
+ *x = EnumType1(num)
return nil
}
+// Deprecated: Use EnumType1.Type instead.
func (EnumType1) EnumDescriptor() ([]byte, []int) {
return xxx_File_proto2_enum_proto_rawdesc_gzipped, []int{0}
}
@@ -81,35 +76,37 @@
return protoreflect.EnumNumber(e)
}
+// Deprecated: Use EnumType2.Type.Values instead.
var EnumType2_name = map[int32]string{
1: "duplicate1",
// Duplicate value: 1: "duplicate2",
}
+// Deprecated: Use EnumType2.Type.Values instead.
var EnumType2_value = map[string]int32{
"duplicate1": 1,
"duplicate2": 1,
}
func (x EnumType2) Enum() *EnumType2 {
- p := new(EnumType2)
- *p = x
- return p
+ return &x
}
func (x EnumType2) String() string {
- return proto.EnumName(EnumType2_name, int32(x))
+ return protoimpl.X.EnumStringOf(x.Type(), protoreflect.EnumNumber(x))
}
-func (x *EnumType2) UnmarshalJSON(data []byte) error {
- value, err := proto.UnmarshalJSONEnum(EnumType2_value, data, "EnumType2")
+// Deprecated: Do not use.
+func (x *EnumType2) UnmarshalJSON(b []byte) error {
+ num, err := protoimpl.X.UnmarshalJSONEnum(x.Type(), b)
if err != nil {
return err
}
- *x = EnumType2(value)
+ *x = EnumType2(num)
return nil
}
+// Deprecated: Use EnumType2.Type instead.
func (EnumType2) EnumDescriptor() ([]byte, []int) {
return xxx_File_proto2_enum_proto_rawdesc_gzipped, []int{1}
}
@@ -129,33 +126,35 @@
return protoreflect.EnumNumber(e)
}
+// Deprecated: Use EnumContainerMessage1_NestedEnumType1A.Type.Values instead.
var EnumContainerMessage1_NestedEnumType1A_name = map[int32]string{
0: "NESTED_1A_VALUE",
}
+// Deprecated: Use EnumContainerMessage1_NestedEnumType1A.Type.Values instead.
var EnumContainerMessage1_NestedEnumType1A_value = map[string]int32{
"NESTED_1A_VALUE": 0,
}
func (x EnumContainerMessage1_NestedEnumType1A) Enum() *EnumContainerMessage1_NestedEnumType1A {
- p := new(EnumContainerMessage1_NestedEnumType1A)
- *p = x
- return p
+ return &x
}
func (x EnumContainerMessage1_NestedEnumType1A) String() string {
- return proto.EnumName(EnumContainerMessage1_NestedEnumType1A_name, int32(x))
+ return protoimpl.X.EnumStringOf(x.Type(), protoreflect.EnumNumber(x))
}
-func (x *EnumContainerMessage1_NestedEnumType1A) UnmarshalJSON(data []byte) error {
- value, err := proto.UnmarshalJSONEnum(EnumContainerMessage1_NestedEnumType1A_value, data, "EnumContainerMessage1_NestedEnumType1A")
+// Deprecated: Do not use.
+func (x *EnumContainerMessage1_NestedEnumType1A) UnmarshalJSON(b []byte) error {
+ num, err := protoimpl.X.UnmarshalJSONEnum(x.Type(), b)
if err != nil {
return err
}
- *x = EnumContainerMessage1_NestedEnumType1A(value)
+ *x = EnumContainerMessage1_NestedEnumType1A(num)
return nil
}
+// Deprecated: Use EnumContainerMessage1_NestedEnumType1A.Type instead.
func (EnumContainerMessage1_NestedEnumType1A) EnumDescriptor() ([]byte, []int) {
return xxx_File_proto2_enum_proto_rawdesc_gzipped, []int{0, 0}
}
@@ -173,33 +172,35 @@
return protoreflect.EnumNumber(e)
}
+// Deprecated: Use EnumContainerMessage1_NestedEnumType1B.Type.Values instead.
var EnumContainerMessage1_NestedEnumType1B_name = map[int32]string{
0: "NESTED_1B_VALUE",
}
+// Deprecated: Use EnumContainerMessage1_NestedEnumType1B.Type.Values instead.
var EnumContainerMessage1_NestedEnumType1B_value = map[string]int32{
"NESTED_1B_VALUE": 0,
}
func (x EnumContainerMessage1_NestedEnumType1B) Enum() *EnumContainerMessage1_NestedEnumType1B {
- p := new(EnumContainerMessage1_NestedEnumType1B)
- *p = x
- return p
+ return &x
}
func (x EnumContainerMessage1_NestedEnumType1B) String() string {
- return proto.EnumName(EnumContainerMessage1_NestedEnumType1B_name, int32(x))
+ return protoimpl.X.EnumStringOf(x.Type(), protoreflect.EnumNumber(x))
}
-func (x *EnumContainerMessage1_NestedEnumType1B) UnmarshalJSON(data []byte) error {
- value, err := proto.UnmarshalJSONEnum(EnumContainerMessage1_NestedEnumType1B_value, data, "EnumContainerMessage1_NestedEnumType1B")
+// Deprecated: Do not use.
+func (x *EnumContainerMessage1_NestedEnumType1B) UnmarshalJSON(b []byte) error {
+ num, err := protoimpl.X.UnmarshalJSONEnum(x.Type(), b)
if err != nil {
return err
}
- *x = EnumContainerMessage1_NestedEnumType1B(value)
+ *x = EnumContainerMessage1_NestedEnumType1B(num)
return nil
}
+// Deprecated: Use EnumContainerMessage1_NestedEnumType1B.Type instead.
func (EnumContainerMessage1_NestedEnumType1B) EnumDescriptor() ([]byte, []int) {
return xxx_File_proto2_enum_proto_rawdesc_gzipped, []int{0, 1}
}
@@ -219,33 +220,35 @@
return protoreflect.EnumNumber(e)
}
+// Deprecated: Use EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A.Type.Values instead.
var EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A_name = map[int32]string{
0: "NESTED_2A_VALUE",
}
+// Deprecated: Use EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A.Type.Values instead.
var EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A_value = map[string]int32{
"NESTED_2A_VALUE": 0,
}
func (x EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A) Enum() *EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A {
- p := new(EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A)
- *p = x
- return p
+ return &x
}
func (x EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A) String() string {
- return proto.EnumName(EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A_name, int32(x))
+ return protoimpl.X.EnumStringOf(x.Type(), protoreflect.EnumNumber(x))
}
-func (x *EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A) UnmarshalJSON(data []byte) error {
- value, err := proto.UnmarshalJSONEnum(EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A_value, data, "EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A")
+// Deprecated: Do not use.
+func (x *EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A) UnmarshalJSON(b []byte) error {
+ num, err := protoimpl.X.UnmarshalJSONEnum(x.Type(), b)
if err != nil {
return err
}
- *x = EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A(value)
+ *x = EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A(num)
return nil
}
+// Deprecated: Use EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A.Type instead.
func (EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A) EnumDescriptor() ([]byte, []int) {
return xxx_File_proto2_enum_proto_rawdesc_gzipped, []int{0, 0, 0}
}
@@ -263,33 +266,35 @@
return protoreflect.EnumNumber(e)
}
+// Deprecated: Use EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B.Type.Values instead.
var EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B_name = map[int32]string{
0: "NESTED_2B_VALUE",
}
+// Deprecated: Use EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B.Type.Values instead.
var EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B_value = map[string]int32{
"NESTED_2B_VALUE": 0,
}
func (x EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B) Enum() *EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B {
- p := new(EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B)
- *p = x
- return p
+ return &x
}
func (x EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B) String() string {
- return proto.EnumName(EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B_name, int32(x))
+ return protoimpl.X.EnumStringOf(x.Type(), protoreflect.EnumNumber(x))
}
-func (x *EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B) UnmarshalJSON(data []byte) error {
- value, err := proto.UnmarshalJSONEnum(EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B_value, data, "EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B")
+// Deprecated: Do not use.
+func (x *EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B) UnmarshalJSON(b []byte) error {
+ num, err := protoimpl.X.UnmarshalJSONEnum(x.Type(), b)
if err != nil {
return err
}
- *x = EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B(value)
+ *x = EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B(num)
return nil
}
+// Deprecated: Use EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B.Type instead.
func (EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B) EnumDescriptor() ([]byte, []int) {
return xxx_File_proto2_enum_proto_rawdesc_gzipped, []int{0, 0, 1}
}
@@ -308,6 +313,8 @@
func (m *EnumContainerMessage1) Reset() { *m = EnumContainerMessage1{} }
func (m *EnumContainerMessage1) String() string { return proto.CompactTextString(m) }
func (*EnumContainerMessage1) ProtoMessage() {}
+
+// Deprecated: Use EnumContainerMessage1.ProtoReflect.Type instead.
func (*EnumContainerMessage1) Descriptor() ([]byte, []int) {
return xxx_File_proto2_enum_proto_rawdesc_gzipped, []int{0}
}
@@ -363,6 +370,8 @@
return proto.CompactTextString(m)
}
func (*EnumContainerMessage1_EnumContainerMessage2) ProtoMessage() {}
+
+// Deprecated: Use EnumContainerMessage1_EnumContainerMessage2.ProtoReflect.Type instead.
func (*EnumContainerMessage1_EnumContainerMessage2) Descriptor() ([]byte, []int) {
return xxx_File_proto2_enum_proto_rawdesc_gzipped, []int{0, 0}
}
@@ -440,7 +449,7 @@
0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32,
}
-var xxx_File_proto2_enum_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_proto2_enum_proto_rawdesc)
+var xxx_File_proto2_enum_proto_rawdesc_gzipped = protoimpl.X.CompressGZIP(xxx_File_proto2_enum_proto_rawdesc)
const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
diff --git a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
index 359cafc..7d03b09 100644
--- a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
@@ -5,19 +5,12 @@
import (
proto "github.com/golang/protobuf/proto"
- protoapi "github.com/golang/protobuf/protoapi"
protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
math "math"
reflect "reflect"
)
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
-
type FieldTestMessage_Enum int32
const (
@@ -32,35 +25,37 @@
return protoreflect.EnumNumber(e)
}
+// Deprecated: Use FieldTestMessage_Enum.Type.Values instead.
var FieldTestMessage_Enum_name = map[int32]string{
0: "ZERO",
1: "ONE",
}
+// Deprecated: Use FieldTestMessage_Enum.Type.Values instead.
var FieldTestMessage_Enum_value = map[string]int32{
"ZERO": 0,
"ONE": 1,
}
func (x FieldTestMessage_Enum) Enum() *FieldTestMessage_Enum {
- p := new(FieldTestMessage_Enum)
- *p = x
- return p
+ return &x
}
func (x FieldTestMessage_Enum) String() string {
- return proto.EnumName(FieldTestMessage_Enum_name, int32(x))
+ return protoimpl.X.EnumStringOf(x.Type(), protoreflect.EnumNumber(x))
}
-func (x *FieldTestMessage_Enum) UnmarshalJSON(data []byte) error {
- value, err := proto.UnmarshalJSONEnum(FieldTestMessage_Enum_value, data, "FieldTestMessage_Enum")
+// Deprecated: Do not use.
+func (x *FieldTestMessage_Enum) UnmarshalJSON(b []byte) error {
+ num, err := protoimpl.X.UnmarshalJSONEnum(x.Type(), b)
if err != nil {
return err
}
- *x = FieldTestMessage_Enum(value)
+ *x = FieldTestMessage_Enum(num)
return nil
}
+// Deprecated: Use FieldTestMessage_Enum.Type instead.
func (FieldTestMessage_Enum) EnumDescriptor() ([]byte, []int) {
return xxx_File_proto2_fields_proto_rawdesc_gzipped, []int{0, 0}
}
@@ -183,6 +178,8 @@
func (m *FieldTestMessage) Reset() { *m = FieldTestMessage{} }
func (m *FieldTestMessage) String() string { return proto.CompactTextString(m) }
func (*FieldTestMessage) ProtoMessage() {}
+
+// Deprecated: Use FieldTestMessage.ProtoReflect.Type instead.
func (*FieldTestMessage) Descriptor() ([]byte, []int) {
return xxx_File_proto2_fields_proto_rawdesc_gzipped, []int{0}
}
@@ -1135,6 +1132,8 @@
func (m *FieldTestMessage_OptionalGroup) Reset() { *m = FieldTestMessage_OptionalGroup{} }
func (m *FieldTestMessage_OptionalGroup) String() string { return proto.CompactTextString(m) }
func (*FieldTestMessage_OptionalGroup) ProtoMessage() {}
+
+// Deprecated: Use FieldTestMessage_OptionalGroup.ProtoReflect.Type instead.
func (*FieldTestMessage_OptionalGroup) Descriptor() ([]byte, []int) {
return xxx_File_proto2_fields_proto_rawdesc_gzipped, []int{0, 0}
}
@@ -1177,6 +1176,8 @@
func (m *FieldTestMessage_RequiredGroup) Reset() { *m = FieldTestMessage_RequiredGroup{} }
func (m *FieldTestMessage_RequiredGroup) String() string { return proto.CompactTextString(m) }
func (*FieldTestMessage_RequiredGroup) ProtoMessage() {}
+
+// Deprecated: Use FieldTestMessage_RequiredGroup.ProtoReflect.Type instead.
func (*FieldTestMessage_RequiredGroup) Descriptor() ([]byte, []int) {
return xxx_File_proto2_fields_proto_rawdesc_gzipped, []int{0, 1}
}
@@ -1219,6 +1220,8 @@
func (m *FieldTestMessage_RepeatedGroup) Reset() { *m = FieldTestMessage_RepeatedGroup{} }
func (m *FieldTestMessage_RepeatedGroup) String() string { return proto.CompactTextString(m) }
func (*FieldTestMessage_RepeatedGroup) ProtoMessage() {}
+
+// Deprecated: Use FieldTestMessage_RepeatedGroup.ProtoReflect.Type instead.
func (*FieldTestMessage_RepeatedGroup) Descriptor() ([]byte, []int) {
return xxx_File_proto2_fields_proto_rawdesc_gzipped, []int{0, 2}
}
@@ -1261,6 +1264,8 @@
func (m *FieldTestMessage_OneofGroup) Reset() { *m = FieldTestMessage_OneofGroup{} }
func (m *FieldTestMessage_OneofGroup) String() string { return proto.CompactTextString(m) }
func (*FieldTestMessage_OneofGroup) ProtoMessage() {}
+
+// Deprecated: Use FieldTestMessage_OneofGroup.ProtoReflect.Type instead.
func (*FieldTestMessage_OneofGroup) Descriptor() ([]byte, []int) {
return xxx_File_proto2_fields_proto_rawdesc_gzipped, []int{0, 6}
}
@@ -1302,6 +1307,8 @@
func (m *FieldTestMessage_Message) Reset() { *m = FieldTestMessage_Message{} }
func (m *FieldTestMessage_Message) String() string { return proto.CompactTextString(m) }
func (*FieldTestMessage_Message) ProtoMessage() {}
+
+// Deprecated: Use FieldTestMessage_Message.ProtoReflect.Type instead.
func (*FieldTestMessage_Message) Descriptor() ([]byte, []int) {
return xxx_File_proto2_fields_proto_rawdesc_gzipped, []int{0, 7}
}
@@ -1712,7 +1719,7 @@
0x74, 0x61, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32,
}
-var xxx_File_proto2_fields_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_proto2_fields_proto_rawdesc)
+var xxx_File_proto2_fields_proto_rawdesc_gzipped = protoimpl.X.CompressGZIP(xxx_File_proto2_fields_proto_rawdesc)
const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
diff --git a/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go b/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
index 29ef913..4870f39 100644
--- a/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/nested_messages.pb.go
@@ -5,18 +5,11 @@
import (
proto "github.com/golang/protobuf/proto"
- protoapi "github.com/golang/protobuf/protoapi"
protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
reflect "reflect"
)
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
-
type Layer1 struct {
L2 *Layer1_Layer2 `protobuf:"bytes,1,opt,name=l2" json:"l2,omitempty"`
L3 *Layer1_Layer2_Layer3 `protobuf:"bytes,2,opt,name=l3" json:"l3,omitempty"`
@@ -31,6 +24,8 @@
func (m *Layer1) Reset() { *m = Layer1{} }
func (m *Layer1) String() string { return proto.CompactTextString(m) }
func (*Layer1) ProtoMessage() {}
+
+// Deprecated: Use Layer1.ProtoReflect.Type instead.
func (*Layer1) Descriptor() ([]byte, []int) {
return xxx_File_proto2_nested_messages_proto_rawdesc_gzipped, []int{0}
}
@@ -80,6 +75,8 @@
func (m *Layer1_Layer2) Reset() { *m = Layer1_Layer2{} }
func (m *Layer1_Layer2) String() string { return proto.CompactTextString(m) }
func (*Layer1_Layer2) ProtoMessage() {}
+
+// Deprecated: Use Layer1_Layer2.ProtoReflect.Type instead.
func (*Layer1_Layer2) Descriptor() ([]byte, []int) {
return xxx_File_proto2_nested_messages_proto_rawdesc_gzipped, []int{0, 0}
}
@@ -121,6 +118,8 @@
func (m *Layer1_Layer2_Layer3) Reset() { *m = Layer1_Layer2_Layer3{} }
func (m *Layer1_Layer2_Layer3) String() string { return proto.CompactTextString(m) }
func (*Layer1_Layer2_Layer3) ProtoMessage() {}
+
+// Deprecated: Use Layer1_Layer2_Layer3.ProtoReflect.Type instead.
func (*Layer1_Layer2_Layer3) Descriptor() ([]byte, []int) {
return xxx_File_proto2_nested_messages_proto_rawdesc_gzipped, []int{0, 0, 0}
}
@@ -175,7 +174,7 @@
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32,
}
-var xxx_File_proto2_nested_messages_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_proto2_nested_messages_proto_rawdesc)
+var xxx_File_proto2_nested_messages_proto_rawdesc_gzipped = protoimpl.X.CompressGZIP(xxx_File_proto2_nested_messages_proto_rawdesc)
const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
diff --git a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
index cd10eb4..759bfb8 100644
--- a/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/proto2.pb.go
@@ -5,18 +5,11 @@
import (
proto "github.com/golang/protobuf/proto"
- protoapi "github.com/golang/protobuf/protoapi"
protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
reflect "reflect"
)
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
-
type Message struct {
I32 *int32 `protobuf:"varint,1,opt,name=i32" json:"i32,omitempty"`
M *Message `protobuf:"bytes,2,opt,name=m" json:"m,omitempty"`
@@ -31,6 +24,8 @@
func (m *Message) Reset() { *m = Message{} }
func (m *Message) String() string { return proto.CompactTextString(m) }
func (*Message) ProtoMessage() {}
+
+// Deprecated: Use Message.ProtoReflect.Type instead.
func (*Message) Descriptor() ([]byte, []int) {
return xxx_File_proto2_proto2_proto_rawdesc_gzipped, []int{0}
}
@@ -88,7 +83,7 @@
0x61, 0x74, 0x61, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32,
}
-var xxx_File_proto2_proto2_proto_rawdesc_gzipped = protoapi.CompressGZIP(xxx_File_proto2_proto2_proto_rawdesc)
+var xxx_File_proto2_proto2_proto_rawdesc_gzipped = protoimpl.X.CompressGZIP(xxx_File_proto2_proto2_proto_rawdesc)
const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)