MCPcopy
hub / github.com/golang/protobuf / FileDescriptor

Function FileDescriptor

proto/registry.go:58–75  ·  view source on GitHub ↗

FileDescriptor returns the compressed FileDescriptorProto given the file path for a proto source file. It returns nil if not found. Deprecated: Use protoregistry.GlobalFiles.FindFileByPath instead.

(s filePath)

Source from the content-addressed store, hash-verified

56//
57// Deprecated: Use protoregistry.GlobalFiles.FindFileByPath instead.
58func FileDescriptor(s filePath) fileDescGZIP {
59 if v, ok := fileCache.Load(s); ok {
60 return v.(fileDescGZIP)
61 }
62
63 // Find the descriptor in the v2 registry.
64 var b []byte
65 if fd, _ := protoregistry.GlobalFiles.FindFileByPath(s); fd != nil {
66 b, _ = Marshal(protodesc.ToFileDescriptorProto(fd))
67 }
68
69 // Locally cache the raw descriptor form for the file.
70 if len(b) > 0 {
71 v, _ := fileCache.LoadOrStore(s, protoimpl.X.CompressGZIP(b))
72 return v.(fileDescGZIP)
73 }
74 return nil
75}
76
77// enumName is the name of an enum. For historical reasons, the enum name is
78// neither the full Go name nor the full protobuf name of the enum.

Callers 1

TestRegistryFunction · 0.92

Calls 1

MarshalFunction · 0.85

Tested by 1

TestRegistryFunction · 0.74