func (cdc *Codec) UnmarshalBinaryReader(r io.Reader, ptr interface{}, maxSize int64) (n int64, err error) {
	if maxSize < 0 {
		panic("maxSize cannot be negative.")
	}
	var l int64
	var buf [binary.MaxVarintLen64]byte
	for i := 0; i < len(buf); i++ {
		_, err = r.Read(buf[i : i+1])
		if err != nil {
			return
		}
		n += 1
		if buf[i]&0x80 == 0 {
			break
		}
		if n >= maxSize {
			err = fmt.Errorf("Read overflow, maxSize is %v but uvarint(length-prefix) is itself greater than maxSize.", maxSize)
		}
	}
	u64, _ := binary.Uvarint(buf[:])
	if err != nil {
		return
	}
	if maxSize > 0 {
		if uint64(maxSize) < u64 {
			err = fmt.Errorf("Read overflow, maxSize is %v but this amino binary object is %v bytes.", maxSize, u64)
			return
		}
		if (maxSize - n) < int64(u64) {
			err = fmt.Errorf("Read overflow, maxSize is %v but this length-prefixed amino binary object is %v+%v bytes.", maxSize, n, u64)
			return
		}
	}
	l = int64(u64)
	if l < 0 {
		err = fmt.Errorf("Read overflow, this implementation can't read this because, why would anyone have this much data? Hello from 2018.")
	}
	var bz = make([]byte, l, l)
	_, err = io.ReadFull(r, bz)
	if err != nil {
		return
	}
	n += l
	err = cdc.UnmarshalBinaryBare(bz, ptr)
	return
}
Like UnmarshalBinaryBare, but will first read the byte-length prefix.
UnmarshalBinaryReader will panic if ptr is a nil-pointer.
If maxSize is 0, there is no limit (not recommended).
package amino
import (
	"bytes"
	"encoding/binary"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"reflect"
)
var gcdc *Codec
func init() {
	gcdc = NewCodec().Seal()
}
func MarshalBinary(o interface{}) ([]byte, error) {
	return gcdc.MarshalBinary(o)
}
func MarshalBinaryWriter(w io.Writer, o interface{}) (n int64, err error) {
	return gcdc.MarshalBinaryWriter(w, o)
}
func MustMarshalBinary(o interface{}) []byte {
	return gcdc.MustMarshalBinary(o)
}
func MarshalBinaryBare(o interface{}) ([]byte, error) {
	return gcdc.MarshalBinaryBare(o)
}
func MustMarshalBinaryBare(o interface{}) []byte {
	return gcdc.MustMarshalBinaryBare(o)
}
func UnmarshalBinary(bz []byte, ptr interface{}) error {
	return gcdc.UnmarshalBinary(bz, ptr)
}
func UnmarshalBinaryReader(r io.Reader, ptr interface{}, maxSize int64) (n int64, err error) {
	return gcdc.UnmarshalBinaryReader(r, ptr, maxSize)
}
func MustUnmarshalBinary(bz []byte, ptr interface{}) {
	gcdc.MustUnmarshalBinary(bz, ptr)
}
func UnmarshalBinaryBare(bz []byte, ptr interface{}) error {
	return gcdc.UnmarshalBinaryBare(bz, ptr)
}
func MustUnmarshalBinaryBare(bz []byte, ptr interface{}) {
	gcdc.MustUnmarshalBinaryBare(bz, ptr)
}
func MarshalJSON(o interface{}) ([]byte, error) {
	return gcdc.MarshalJSON(o)
}
func UnmarshalJSON(bz []byte, ptr interface{}) error {
	return gcdc.UnmarshalJSON(bz, ptr)
}
func MarshalJSONIndent(o interface{}, prefix, indent string) ([]byte, error) {
	return gcdc.MarshalJSONIndent(o, prefix, indent)
}
type Typ3 uint8
const (
	Typ3_Varint     = Typ3(0)
	Typ3_8Byte      = Typ3(1)
	Typ3_ByteLength = Typ3(2)
	Typ3_4Byte = Typ3(5)
)
func (typ Typ3) String() string {
	switch typ {
	case Typ3_Varint:
		return "(U)Varint"
	case Typ3_8Byte:
		return "8Byte"
	case Typ3_ByteLength:
		return "ByteLength"
	case Typ3_4Byte:
		return "4Byte"
	default:
		return fmt.Sprintf("<Invalid Typ3 %X>", byte(typ))
	}
}
func (cdc *Codec) MarshalBinary(o interface{}) ([]byte, error) {
	var buf = new(bytes.Buffer)
	bz, err := cdc.MarshalBinaryBare(o)
	if err != nil {
		return nil, err
	}
	err = EncodeUvarint(buf, uint64(len(bz)))
	if err != nil {
		return nil, err
	}
	_, err = buf.Write(bz)
	if err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}
func (cdc *Codec) MarshalBinaryWriter(w io.Writer, o interface{}) (n int64, err error) {
	var bz, _n = []byte(nil), int(0)
	bz, err = cdc.MarshalBinary(o)
	if err != nil {
		return 0, err
	}
	_n, err = w.Write(bz)  
	n = int64(_n)
	return
}
func (cdc *Codec) MustMarshalBinary(o interface{}) []byte {
	bz, err := cdc.MarshalBinary(o)
	if err != nil {
		panic(err)
	}
	return bz
}
func (cdc *Codec) MarshalBinaryBare(o interface{}) ([]byte, error) {
	var rv, _, isNilPtr = derefPointers(reflect.ValueOf(o))
	if isNilPtr {
		panic("MarshalBinary cannot marshal a nil pointer directly. Try wrapping in a struct?")
	}
	var bz []byte
	buf := new(bytes.Buffer)
	rt := rv.Type()
	info, err := cdc.getTypeInfo_wlock(rt)
	if err != nil {
		return nil, err
	}
	err = cdc.encodeReflectBinary(buf, info, rv, FieldOptions{}, true)
	if err != nil {
		return nil, err
	}
	bz = buf.Bytes()
	if info.Registered {
		pb := info.Prefix.Bytes()
		bz = append(pb, bz...)
	}
	return bz, nil
}
func (cdc *Codec) MustMarshalBinaryBare(o interface{}) []byte {
	bz, err := cdc.MarshalBinaryBare(o)
	if err != nil {
		panic(err)
	}
	return bz
}
func (cdc *Codec) UnmarshalBinary(bz []byte, ptr interface{}) error {
	if len(bz) == 0 {
		return errors.New("UnmarshalBinary cannot decode empty bytes")
	}
	u64, n := binary.Uvarint(bz)
	if n < 0 {
		return fmt.Errorf("Error reading msg byte-length prefix: got code %v", n)
	}
	if u64 > uint64(len(bz)-n) {
		return fmt.Errorf("Not enough bytes to read in UnmarshalBinary, want %v more bytes but only have %v",
			u64, len(bz)-n)
	} else if u64 < uint64(len(bz)-n) {
		return fmt.Errorf("Bytes left over in UnmarshalBinary, should read %v more bytes but have %v",
			u64, len(bz)-n)
	}
	bz = bz[n:]
	return cdc.UnmarshalBinaryBare(bz, ptr)
}