func (s *Serializer) WriteVarSlice(val []byte) error {
	err := s.WriteVarInt(uint64(len(val)))
	if err != nil {
		return err
	}
	return s.WriteSlice(val)
}
WriteVarSlice appends the length of the given byte array as var int
and the byte array itself to the writer's buffer
package bufferutil
import (
	"bytes"
)
type Serializer struct {
	buffer *bytes.Buffer
}
func NewSerializer(buf *bytes.Buffer) (*Serializer, error) {
	buffer := bytes.NewBuffer([]byte{})
	if buf != nil {
		_, err := buffer.Write(buf.Bytes())
		if err != nil {
			return nil, err
		}
	}
	return &Serializer{buffer}, nil
}
func (s *Serializer) Bytes() []byte {
	return s.buffer.Bytes()
}
func (s *Serializer) WriteUint8(val uint8) error {
	return BinarySerializer.PutUint8(s.buffer, val)
}
func (s *Serializer) WriteUint16(val uint16) error {
	return BinarySerializer.PutUint16(s.buffer, littleEndian, val)
}
func (s *Serializer) WriteUint32(val uint32) error {
	return BinarySerializer.PutUint32(s.buffer, littleEndian, val)
}
func (s *Serializer) WriteUint64(val uint64) error {
	return BinarySerializer.PutUint64(s.buffer, littleEndian, val)
}
func (s *Serializer) WriteVarInt(val uint64) error {
	return writeVarInt(s.buffer, val)
}
func (s *Serializer) WriteSlice(val []byte) error {
	_, err := s.buffer.Write(val)
	return err
}