NewMessage returns a new dynamic proto.Message for the fully qualified typeName in the bufimage.Image.
( ctx context.Context, image bufimage.Image, typeName string, )
| 26 | // NewMessage returns a new dynamic proto.Message for the fully qualified typeName |
| 27 | // in the bufimage.Image. |
| 28 | func NewMessage( |
| 29 | ctx context.Context, |
| 30 | image bufimage.Image, |
| 31 | typeName string, |
| 32 | ) (proto.Message, error) { |
| 33 | if err := ValidateTypeName(typeName); err != nil { |
| 34 | return nil, err |
| 35 | } |
| 36 | messageType, err := image.Resolver().FindMessageByName(protoreflect.FullName(typeName)) |
| 37 | if err != nil { |
| 38 | return nil, err |
| 39 | } |
| 40 | return messageType.New().Interface(), nil |
| 41 | } |
| 42 | |
| 43 | // ValidateTypeName validates that the typeName is well-formed, such that it has one or more |
| 44 | // '.'-delimited package components and no '/' elements. |
no test coverage detected
searching dependent graphs…