pub.go
func (c Pub) Write(w *bufio.Writer) (err error) {
	for _, s := range [...]string{
		"PUB ",
		c.Topic,
		"\n",
	} {
		if _, err = w.WriteString(s); err != nil {
			err = errors.Wrap(err, "writing PUB command")
			return
		}
	}

	if err = binary.Write(w, binary.BigEndian, uint32(len(c.Message))); err != nil {
		err = errors.Wrap(err, "writing PUB message size")
		return
	}

	if _, err = w.Write(c.Message); err != nil {
		err = errors.Wrap(err, "writing PUB message data")
		return
	}

	return
}
func (c Pub) Write(w *bufio.Writer) (err error) {
	for _, s := range [...]string{
		"PUB ",
		c.Topic,
		"\n",
	} {
		if _, err = w.WriteString(s); err != nil {
			err = errors.Wrap(err, "writing PUB command")
			return
		}
	}

	if err = binary.Write(w, binary.BigEndian, uint32(len(c.Message))); err != nil {
		err = errors.Wrap(err, "writing PUB message size")
		return
	}

	if _, err = w.Write(c.Message); err != nil {
		err = errors.Wrap(err, "writing PUB message data")
		return
	}

	return
}
// Write serializes the command to the given buffered output, satisfies the
// Command interface.