message.go
func (m Message) Write(w *bufio.Writer) (err error) {
	if err = writeFrameHeader(w, FrameTypeMessage, len(m.Body)+26); err != nil {
		err = errors.WithMessage(err, "writing message")
		return
	}

	if err = binary.Write(w, binary.BigEndian, m.Timestamp.UnixNano()); err != nil {
		err = errors.Wrap(err, "writing message")
		return
	}

	if err = binary.Write(w, binary.BigEndian, m.Attempts); err != nil {
		err = errors.Wrap(err, "writing message")
		return
	}

	if _, err = m.ID.WriteTo(w); err != nil {
		err = errors.Wrap(err, "writing message")
		return
	}

	if _, err = w.Write(m.Body); err != nil {
		err = errors.Wrap(err, "writing message")
		return
	}

	return
}
func (m Message) Write(w *bufio.Writer) (err error) {
	if err = writeFrameHeader(w, FrameTypeMessage, len(m.Body)+26); err != nil {
		err = errors.WithMessage(err, "writing message")
		return
	}

	if err = binary.Write(w, binary.BigEndian, m.Timestamp.UnixNano()); err != nil {
		err = errors.Wrap(err, "writing message")
		return
	}

	if err = binary.Write(w, binary.BigEndian, m.Attempts); err != nil {
		err = errors.Wrap(err, "writing message")
		return
	}

	if _, err = m.ID.WriteTo(w); err != nil {
		err = errors.Wrap(err, "writing message")
		return
	}

	if _, err = w.Write(m.Body); err != nil {
		err = errors.Wrap(err, "writing message")
		return
	}

	return
}
// Write serializes the frame to the given buffered output, satisfies the Frame
// interface.