MCPcopy
hub / github.com/protocolbuffers/protobuf-go / FindEnumByName

Method FindEnumByName

types/dynamicpb/types.go:52–62  ·  view source on GitHub ↗

FindEnumByName looks up an enum by its full name; e.g., "google.protobuf.Field.Kind". This returns (nil, [protoregistry.NotFound]) if not found.

(name protoreflect.FullName)

Source from the content-addressed store, hash-verified

50//
51// This returns (nil, [protoregistry.NotFound]) if not found.
52func (t *Types) FindEnumByName(name protoreflect.FullName) (protoreflect.EnumType, error) {
53 d, err := t.files.FindDescriptorByName(name)
54 if err != nil {
55 return nil, err
56 }
57 ed, ok := d.(protoreflect.EnumDescriptor)
58 if !ok {
59 return nil, errors.New("found wrong type: got %v, want enum", descName(d))
60 }
61 return NewEnumType(ed), nil
62}
63
64// FindExtensionByName looks up an extension field by the field's full name.
65// Note that this is the full name of the field as determined by

Calls 4

NewFunction · 0.92
descNameFunction · 0.85
NewEnumTypeFunction · 0.85
FindDescriptorByNameMethod · 0.65

Tested by 3