-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
even after defining an extension, calling proto.HasExtension(fd.Options, pb.E_MyExtension)
always returns false
.
On my machine, FieldOptions
has the following methods:
func (m *FieldOptions) Reset() { *m = FieldOptions{} }
func (m *FieldOptions) String() string { return proto.CompactTextString(m) }
func (*FieldOptions) ProtoMessage() {}
func (*FieldOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} }
var extRange_FieldOptions = []proto.ExtensionRange{
{1000, 536870911},
}
func (*FieldOptions) ExtensionRangeArray() []proto.ExtensionRange {
return extRange_FieldOptions
}
but HasExtension
checks whether the message is extendable
:
// extendableProto is an interface implemented by any protocol buffer generated by the current
// proto compiler that may be extended.
type extendableProto interface {
Message
ExtensionRangeArray() []ExtensionRange
extensionsWrite() map[int32]Extension
extensionsRead() (map[int32]Extension, sync.Locker)
}
// extendableProtoV1 is an interface implemented by a protocol buffer generated by the previous
// version of the proto compiler that may be extended.
type extendableProtoV1 interface {
Message
ExtensionRangeArray() []ExtensionRange
ExtensionMap() map[int32]Extension
}
...
// extendable returns the extendableProto interface for the given generated proto message.
// If the proto message has the old extension format, it returns a wrapper that implements
// the extendableProto interface.
func extendable(p interface{}) (extendableProto, bool) {
if ep, ok := p.(extendableProto); ok {
return ep, ok
}
if ep, ok := p.(extendableProtoV1); ok {
return extensionAdapter{ep}, ok
}
return nil, false
}
but it looks like FieldOptions
does not have the extensionsWrite
and extensionsRead
methods, so this fails immediately.
Metadata
Metadata
Assignees
Labels
No labels