func (mw *Writer) WriteUint64(u uint64) error {
	switch {
	case u <= math.MaxInt8:
		return mw.push(wfixint(uint8(u)))
	case u <= math.MaxUint8:
		return mw.prefix8(muint8, uint8(u))
	case u <= math.MaxUint16:
		return mw.prefix16(muint16, uint16(u))
	case u <= math.MaxUint32:
		return mw.prefix32(muint32, uint32(u))
	default:
		return mw.prefix64(muint64, u)
	}
}
WriteUint64 writes a uint64 to the writer.
package msgp
import (
	"errors"
	"fmt"
	"io"
	"math"
	"reflect"
	"time"
)
type Sizer interface {
	Msgsize() int
}
var btsType = reflect.TypeOf(([]byte)(nil))
var Nowhere = nwhere{}
type nwhere struct{}
func (nwhere) Write(p []byte) (int, error) { return len(p), nil }
type Marshaler interface {
	MarshalMsg([]byte) ([]byte, error)
}
type Encoder interface {
	EncodeMsg(*Writer) error
}
type MarshalSizer interface {
	Marshaler
	Sizer
}
type Writer struct {
	w    io.Writer
	buf  []byte
	wLoc int  
}
func NewWriter(w io.Writer) *Writer {
	if wr, ok := w.(*Writer); ok && w != nil {
		return wr
	}
	return &Writer{
		buf: make([]byte, 2048),
		w:   w,
	}
}
func NewWriterSize(w io.Writer, sz int) *Writer {
	if sz < 18 {
		sz = 18
	}
	return &Writer{
		w:   w,
		buf: make([]byte, sz),
	}
}
func Encode(w io.Writer, e Encoder) error {
	wr := NewWriter(w)
	err := e.EncodeMsg(wr)
	if err == nil {
		err = wr.Flush()
	}
	return err
}
func (mw *Writer) Flush() error {
	if mw.wLoc == 0 {
		return nil
	}
	n, err := mw.w.Write(mw.buf[:mw.wLoc])
	if err != nil {
		if n > 0 {
			mw.wLoc = copy(mw.buf, mw.buf[n:mw.wLoc])
		}
		return err
	}
	if n < mw.wLoc {
		return io.ErrShortWrite
	}
	mw.wLoc = 0
	return nil
}
func (mw *Writer) OpenSpace() int { return len(mw.buf) - mw.wLoc }
func (mw *Writer) require(n int) (int, error) {
	wl := mw.wLoc
	if mw.OpenSpace() < n {
		if err := mw.Flush(); err != nil {
			return 0, err
		}
		wl = mw.wLoc
	}
	mw.wLoc += n
	return wl, nil
}
func (mw *Writer) Append(bts ...byte) error {
	if mw.OpenSpace() < len(bts) {
		if err := mw.Flush(); err != nil {
			return err
		}
	}
	mw.wLoc += copy(mw.buf[mw.wLoc:], bts)
	return nil
}
func (mw *Writer) push(b byte) error {
	if mw.wLoc == len(mw.buf) {
		if err := mw.Flush(); err != nil {
			return err
		}
	}
	mw.buf[mw.wLoc] = b
	mw.wLoc++
	return nil
}
func (mw *Writer) prefix8(b byte, u uint8) error {
	const need = 2
	if mw.OpenSpace() < need {
		if err := mw.Flush(); err != nil {
			return err
		}
	}
	prefixu8(mw.buf[mw.wLoc:], b, u)
	mw.wLoc += need
	return nil
}
func (mw *Writer) prefix16(b byte, u uint16) error {
	const need = 3
	if mw.OpenSpace() < need {
		if err := mw.Flush(); err != nil {
			return err
		}
	}
	prefixu16(mw.buf[mw.wLoc:], b, u)
	mw.wLoc += need
	return nil
}
func (mw *Writer) prefix32(b byte, u uint32) error {
	const need = 5
	if mw.OpenSpace() < need {
		if err := mw.Flush(); err != nil {
			return err
		}
	}
	prefixu32(mw.buf[mw.wLoc:], b, u)
	mw.wLoc += need
	return nil
}
func (mw *Writer) prefix64(b byte, u uint64) error {
	const need = 9
	if mw.OpenSpace() < need {
		if err := mw.Flush(); err != nil {
			return err
		}
	}
	prefixu64(mw.buf[mw.wLoc:], b, u)
	mw.wLoc += need
	return nil
}
func (mw *Writer) Write(p []byte) (int, error) {
	l := len(p)
	if mw.OpenSpace() < l {
		if err := mw.Flush(); err != nil {
			return 0, err
		}
		if l > len(mw.buf) {
			return mw.w.Write(p)
		}
	}
	mw.wLoc += copy(mw.buf[mw.wLoc:], p)
	return l, nil
}
func (mw *Writer) writeString(s string) error {
	l := len(s)
	if mw.OpenSpace() < l {
		if err := mw.Flush(); err != nil {
			return err
		}
		if l > len(mw.buf) {
			n, err := io.WriteString(mw.w, s)
			if err != nil {
				return err
			}
			if n < l {
				return io.ErrShortWrite
			}
			return nil
		}
	}
	mw.wLoc += copy(mw.buf[mw.wLoc:], s)
	return nil
}
func (mw *Writer) Reset(w io.Writer) {
	mw.buf = mw.buf[:cap(mw.buf)]
	mw.w = w
	mw.wLoc = 0
}
func (mw *Writer) WriteMapHeader(sz uint32) error {
	switch {
	case sz <= 15:
		return mw.push(wfixmap(uint8(sz)))
	case sz <= math.MaxUint16:
		return mw.prefix16(mmap16, uint16(sz))
	default:
		return mw.prefix32(mmap32, sz)
	}
}
func (mw *Writer) WriteArrayHeader(sz uint32) error {
	switch {
	case sz <= 15:
		return mw.push(wfixarray(uint8(sz)))
	case sz <= math.MaxUint16:
		return mw.prefix16(marray16, uint16(sz))
	default:
		return mw.prefix32(marray32, sz)
	}
}
func (mw *Writer) WriteNil() error {
	return mw.push(mnil)
}
func (mw *Writer) WriteFloat64(f float64) error {
	return mw.prefix64(mfloat64, math.Float64bits(f))
}
func (mw *Writer) WriteFloat32(f float32) error {
	return mw.prefix32(mfloat32, math.Float32bits(f))
}
func (mw *Writer) WriteInt64(i int64) error {
	if i >= 0 {
		switch {
		case i <= math.MaxInt8:
			return mw.push(wfixint(uint8(i)))
		case i <= math.MaxInt16:
			return mw.prefix16(mint16, uint16(i))
		case i <= math.MaxInt32:
			return mw.prefix32(mint32, uint32(i))
		default:
			return mw.prefix64(mint64, uint64(i))
		}
	}
	switch {
	case i >= -32:
		return mw.push(wnfixint(int8(i)))
	case i >= math.MinInt8:
		return mw.prefix8(mint8, uint8(i))
	case i >= math.MinInt16:
		return mw.prefix16(mint16, uint16(i))
	case i >= math.MinInt32:
		return mw.prefix32(mint32, uint32(i))
	default:
		return mw.prefix64(mint64, uint64(i))
	}
}
func (mw *Writer) WriteInt8(i int8) error {
	if i >= 0 {
		return mw.push(wfixint(uint8(i)))
	}
	if i >= -32 {
		return mw.push(wnfixint(i))
	}
	return mw.prefix8(mint8, uint8(i))
}
func (mw *Writer) WriteInt16(i int16) error { return mw.WriteInt64(int64(i)) }
func (mw *Writer) WriteInt32(i int32) error { return mw.WriteInt64(int64(i)) }
func (mw *Writer) WriteInt(i int) error { return mw.WriteInt64(int64(i)) }