@@ -25,7 +25,10 @@ import (
25
25
)
26
26
27
27
// Message is proto.Message with a method to return its descriptor.
28
- // Not every message is guaranteed to implement this interface.
28
+ //
29
+ // Deprecated: The Descriptor method may not be generated by future
30
+ // versions of protoc-gen-go, meaning that this interface may not
31
+ // be implemented by many concrete message types.
29
32
type Message interface {
30
33
proto.Message
31
34
Descriptor () ([]byte , []int )
@@ -34,18 +37,15 @@ type Message interface {
34
37
// ForMessage returns the file descriptor proto containing
35
38
// the message and the message descriptor proto for the message itself.
36
39
// The returned proto messages must not be mutated.
40
+ //
41
+ // Deprecated: Not all concrete message types satisfy the Message interface.
42
+ // Use MessageDescriptorProto instead. If possible, the calling code should
43
+ // be rewritten to use protobuf reflection instead.
44
+ // See package "google.golang.org/protobuf/reflect/protoreflect" for details.
37
45
func ForMessage (m Message ) (* descriptorpb.FileDescriptorProto , * descriptorpb.DescriptorProto ) {
38
- return MessageDescriptorProtoOf (m )
46
+ return MessageDescriptorProto (m )
39
47
}
40
48
41
- // GeneratedEnum is any enum type generated by protoc-gen-go
42
- // which is a named int32 kind.
43
- type GeneratedEnum interface {}
44
-
45
- // GeneratedMessage is any message type generated by protoc-gen-go
46
- // which is a pointer to a named struct kind.
47
- type GeneratedMessage interface {}
48
-
49
49
type rawDesc struct {
50
50
fileDesc []byte
51
51
indexes []int
@@ -99,21 +99,21 @@ func deriveRawDescriptor(d protoreflect.Descriptor) ([]byte, []int) {
99
99
return file , idxs
100
100
}
101
101
102
- // EnumRawDescriptorOf returns the GZIP'd raw file descriptor containing the
102
+ // EnumRawDescriptor returns the GZIP'd raw file descriptor containing the
103
103
// enum and the index path to reach the enum declaration.
104
104
// The returned slices must not be mutated.
105
- func EnumRawDescriptorOf (e GeneratedEnum ) ([]byte , []int ) {
105
+ func EnumRawDescriptor (e proto. GeneratedEnum ) ([]byte , []int ) {
106
106
if ev , ok := e .(interface { EnumDescriptor () ([]byte , []int ) }); ok {
107
107
return ev .EnumDescriptor ()
108
108
}
109
109
ed := protoimpl .X .EnumTypeOf (e )
110
110
return deriveRawDescriptor (ed .Descriptor ())
111
111
}
112
112
113
- // MessageRawDescriptorOf returns the GZIP'd raw file descriptor containing
113
+ // MessageRawDescriptor returns the GZIP'd raw file descriptor containing
114
114
// the message and the index path to reach the message declaration.
115
115
// The returned slices must not be mutated.
116
- func MessageRawDescriptorOf (m GeneratedMessage ) ([]byte , []int ) {
116
+ func MessageRawDescriptor (m proto. GeneratedMessage ) ([]byte , []int ) {
117
117
if mv , ok := m .(interface { Descriptor () ([]byte , []int ) }); ok {
118
118
return mv .Descriptor ()
119
119
}
@@ -148,11 +148,11 @@ func deriveFileDescriptor(rawDesc []byte) *descriptorpb.FileDescriptorProto {
148
148
return fd
149
149
}
150
150
151
- // EnumDescriptorProtoOf returns the file descriptor proto containing
151
+ // EnumDescriptorProto returns the file descriptor proto containing
152
152
// the enum and the enum descriptor proto for the enum itself.
153
153
// The returned proto messages must not be mutated.
154
- func EnumDescriptorProtoOf (e GeneratedEnum ) (* descriptorpb.FileDescriptorProto , * descriptorpb.EnumDescriptorProto ) {
155
- rawDesc , idxs := EnumRawDescriptorOf (e )
154
+ func EnumDescriptorProto (e proto. GeneratedEnum ) (* descriptorpb.FileDescriptorProto , * descriptorpb.EnumDescriptorProto ) {
155
+ rawDesc , idxs := EnumRawDescriptor (e )
156
156
if rawDesc == nil || idxs == nil {
157
157
return nil , nil
158
158
}
@@ -168,11 +168,11 @@ func EnumDescriptorProtoOf(e GeneratedEnum) (*descriptorpb.FileDescriptorProto,
168
168
return fd , ed
169
169
}
170
170
171
- // MessageDescriptorProtoOf returns the file descriptor proto containing
171
+ // MessageDescriptorProto returns the file descriptor proto containing
172
172
// the message and the message descriptor proto for the message itself.
173
173
// The returned proto messages must not be mutated.
174
- func MessageDescriptorProtoOf (m GeneratedMessage ) (* descriptorpb.FileDescriptorProto , * descriptorpb.DescriptorProto ) {
175
- rawDesc , idxs := MessageRawDescriptorOf (m )
174
+ func MessageDescriptorProto (m proto. GeneratedMessage ) (* descriptorpb.FileDescriptorProto , * descriptorpb.DescriptorProto ) {
175
+ rawDesc , idxs := MessageRawDescriptor (m )
176
176
if rawDesc == nil || idxs == nil {
177
177
return nil , nil
178
178
}
0 commit comments