func (e *Encoder) PackBool(b bool) error {
	if b {
		e.buf[0] = trueCode
	} else {
		e.buf[0] = falseCode
	}
	_, err := e.w.Write(e.buf[:1])
	return err
}
PackBool writes a Bool value to the MessagePack stream.
package msgpack
import (
	"errors"
	"io"
	"math"
)
var (
	ErrLongStringOrBinary = errors.New("msgpack: long string or binary")
	ErrIllegalSize = errors.New("msgpack: illegal array or map size")
)
type Encoder struct {
	buf         [32]byte
	w           io.Writer
	writeString func(string) (int, error)
	err         error  
}
func NewEncoder(w io.Writer) *Encoder {
	e := &Encoder{
		w: w,
	}
	if ws, ok := w.(interface {
		WriteString(string) (int, error)
	}); ok {
		e.writeString = ws.WriteString
	} else {
		e.writeString = e.writeStringUnopt
	}
	return e
}
func (e *Encoder) writeStringUnopt(s string) (int, error) {
	if len(s) <= len(e.buf) {
		copy(e.buf[:], s)
		return e.w.Write(e.buf[:len(s)])
	}
	return e.w.Write([]byte(s))
}
type numCodes struct {
	c8  byte
	c16 byte
	c32 byte
	c64 byte
}
var (
	stringLenEncodings = &numCodes{
		c8:  string8Code,
		c16: string16Code,
		c32: string32Code,
		c64: 0,
	}
	binaryLenEncodings = &numCodes{
		c8:  binary8Code,
		c16: binary16Code,
		c32: binary32Code,
		c64: 0,
	}
	arrayLenEncodings = &numCodes{
		c8:  0,
		c16: array16Code,
		c32: array32Code,
		c64: 0,
	}
	mapLenEncodings = &numCodes{
		c8:  0,
		c16: map16Code,
		c32: map32Code,
		c64: 0,
	}
	extLenEncodings = &numCodes{
		c8:  ext8Code,
		c16: ext16Code,
		c32: ext32Code,
		c64: 0,
	}
	uintEncodings = &numCodes{
		c8:  uint8Code,
		c16: uint16Code,
		c32: uint32Code,
		c64: uint64Code,
	}
)
func (e *Encoder) encodeNum(fc *numCodes, v uint64) []byte {
	switch {
	case fc.c8 != 0 && v <= math.MaxUint8:
		e.buf[0] = fc.c8
		e.buf[1] = byte(v)
		return e.buf[:2]
	case v <= math.MaxUint16:
		e.buf[0] = fc.c16
		e.buf[1] = byte(v >> 8)
		e.buf[2] = byte(v)
		return e.buf[:3]
	case v <= math.MaxUint32:
		e.buf[0] = fc.c32
		e.buf[1] = byte(v >> 24)
		e.buf[2] = byte(v >> 16)
		e.buf[3] = byte(v >> 8)
		e.buf[4] = byte(v)
		return e.buf[:5]
	default:
		e.buf[0] = fc.c64
		e.buf[1] = byte(v >> 56)
		e.buf[2] = byte(v >> 48)
		e.buf[3] = byte(v >> 40)
		e.buf[4] = byte(v >> 32)
		e.buf[5] = byte(v >> 24)
		e.buf[6] = byte(v >> 16)
		e.buf[7] = byte(v >> 8)
		e.buf[8] = byte(v)
		return e.buf[:9]
	}
}