func NewMessage(
	ctx context.Context,
	image bufimage.Image,
	typeName string,
) (proto.Message, error) {
	if err := ValidateTypeName(typeName); err != nil {
		return nil, err
	}
	files, err := protodesc.NewFiles(bufimage.ImageToFileDescriptorSet(image))
	if err != nil {
		return nil, err
	}
	descriptor, err := files.FindDescriptorByName(protoreflect.FullName(typeName))
	if err != nil {
		return nil, err
	}
	typedDescriptor, ok := descriptor.(protoreflect.MessageDescriptor)
	if !ok {
		return nil, fmt.Errorf("%q must be a message but is a %T", typeName, descriptor)
	}
	return dynamicpb.NewMessage(typedDescriptor), nil
}
// NewMessage returns a new dynamic proto.Message for the fully qualified typeName
// in the bufimage.Image.
NewMessage returns a new dynamic proto.Message for the fully qualified typeName
in the bufimage.Image.
// NewMessage returns a new dynamic proto . Message for the fully qualified typeName // in the bufimage . Image .
func NewMessage(
	ctx context.Context,
	image bufimage.Image,
	typeName string,
) (proto.Message, error) {
	if err := ValidateTypeName(typeName); err != nil {
		return nil, err
	}
	files, err := protodesc.NewFiles(bufimage.ImageToFileDescriptorSet(image))
	if err != nil {
		return nil, err
	}
	descriptor, err := files.FindDescriptorByName(protoreflect.FullName(typeName))
	if err != nil {
		return nil, err
	}
	typedDescriptor, ok := descriptor.(protoreflect.MessageDescriptor)
	if !ok {
		return nil, fmt.Errorf("%q must be a message but is a %T", typeName, descriptor)
	}
	return dynamicpb.NewMessage(typedDescriptor), nil
}
func NewMessage ( ctx context . Context , image bufimage . Image , typeName string , ) ( proto . Message , error ) { if err := ValidateTypeName ( typeName ) ; err != nil { return nil , err } files , err := protodesc . NewFiles ( bufimage . ImageToFileDescriptorSet ( image ) ) if err != nil { return nil , err } descriptor , err := files . FindDescriptorByName ( protoreflect . FullName ( typeName ) ) if err != nil { return nil , err } typedDescriptor , ok := descriptor . ( protoreflect . MessageDescriptor ) if ! ok { return nil , fmt . Errorf ( " " , typeName , descriptor ) } return dynamicpb . NewMessage ( typedDescriptor ) , nil }
NewMessage returns a new dynamic proto.Message for the fully qualified typeName
in the bufimage.Image.
NewMessage returns a new dynamic proto . Message for the fully qualified typeName in the bufimage . Image .