func Encode(w io.Writer, e Encoder) error {
	wr := NewWriter(w)
	err := e.EncodeMsg(wr)
	if err == nil {
		err = wr.Flush()
	}
	return err
}
Encode encodes an Encoder to any io.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),
	}
}