| 87 | } |
| 88 | |
| 89 | func loadFileDescDynamic(b []byte) (*descriptorpb.FileDescriptorProto, protoreflect.FileDescriptor, []byte) { |
| 90 | m := new(descriptorpb.FileDescriptorProto) |
| 91 | if err := proto.Unmarshal(b, m); err != nil { |
| 92 | panic("failed to unmarshal dynamic proto raw descriptor") |
| 93 | } |
| 94 | |
| 95 | fd, err := protodesc.NewFile(m, nil) |
| 96 | if err != nil { |
| 97 | panic(err) |
| 98 | } |
| 99 | |
| 100 | err = protoregistry.GlobalFiles.RegisterFile(fd) |
| 101 | if err != nil { |
| 102 | panic(err) |
| 103 | } |
| 104 | |
| 105 | for i := 0; i < fd.Messages().Len(); i++ { |
| 106 | m := fd.Messages().Get(i) |
| 107 | if err := protoregistry.GlobalTypes.RegisterMessage(dynamicpb.NewMessageType(m)); err != nil { |
| 108 | panic(err) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | return m, fd, b |
| 113 | } |
| 114 | |
| 115 | func init() { |
| 116 | _, fdTestByte = loadFileDesc("reflection/grpc_testing/test.proto") |