func DecodeMessage(name string, data []byte) (protoutil.Message, error) {
	// Get the reflected type of the protocol message.
	rt := proto.MessageType(name)
	if rt == nil {
		return nil, errors.Newf("unknown proto message type %s", name)
	}

	// If the message is known, we should get the pointer to our message.
	if rt.Kind() != reflect.Ptr {
		return nil, errors.AssertionFailedf(
			"expected ptr to message, got %s instead", rt.Kind().String())
	}

	// Construct message of appropriate type, through reflection.
	rt = rt.Elem()
	rv := reflect.New(rt)

	msg, ok := rv.Interface().(protoutil.Message)

	if !ok {
		// Just to be safe;
		return nil, errors.AssertionFailedf(
			"unexpected proto type for %s; expected protoutil.Message, got %T",
			name, rv.Interface())
	}

	// Now, parse data as our proto message.
	if err := protoutil.Unmarshal(data, msg); err != nil {
		return nil, errors.Wrapf(err, "failed to unmarshal proto %s", name)
	}
	return msg, nil
}
// DecodeMessage decodes protocol message specified as its fully
// qualified name, and it's marshaled data, into a protoutil.Message.
DecodeMessage decodes protocol message specified as its fully
qualified name, and it's marshaled data, into a protoutil.Message.
// DecodeMessage decodes protocol message specified as its fully // qualified name and it ' s marshaled data into a protoutil . Message .
func DecodeMessage(name string, data []byte) (protoutil.Message, error) {
	rt := proto.MessageType(name)
	if rt == nil {
		return nil, errors.Newf("unknown proto message type %s", name)
	}
	if rt.Kind() != reflect.Ptr {
		return nil, errors.AssertionFailedf(
			"expected ptr to message, got %s instead", rt.Kind().String())
	}
	rt = rt.Elem()
	rv := reflect.New(rt)
	msg, ok := rv.Interface().(protoutil.Message)
	if !ok {
		return nil, errors.AssertionFailedf(
			"unexpected proto type for %s; expected protoutil.Message, got %T",
			name, rv.Interface())
	}
	if err := protoutil.Unmarshal(data, msg); err != nil {
		return nil, errors.Wrapf(err, "failed to unmarshal proto %s", name)
	}
	return msg, nil
}
func DecodeMessage ( name string , data [ ] byte ) ( protoutil . Message , error ) { rt := proto . MessageType ( name ) if rt == nil { return nil , errors . Newf ( " " , name ) } if rt . Kind ( ) != reflect . Ptr { return nil , errors . AssertionFailedf ( " " , rt . Kind ( ) . String ( ) ) } rt = rt . Elem ( ) rv := reflect . New ( rt ) msg , ok := rv . Interface ( ) . ( protoutil . Message ) if ! ok { return nil , errors . AssertionFailedf ( " " , name , rv . Interface ( ) ) } if err := protoutil . Unmarshal ( data , msg ) ; err != nil { return nil , errors . Wrapf ( err , " " , name ) } return msg , nil }
DecodeMessage decodes protocol message specified as its fully
qualified name, and it's marshaled data, into a protoutil.Message.
DecodeMessage decodes protocol message specified as its fully qualified name and it ' s marshaled data into a protoutil . Message .
// Get the reflected type of the protocol message. // If the message is known, we should get the pointer to our message. // Construct message of appropriate type, through reflection. // Just to be safe; // Now, parse data as our proto message.