func (bdr *binaryDecoderReader) ReadLong() (int64, error) {
	var value uint64
	var offset int
	var dest [1]byte
	for {
		if offset == maxLongBufSize {
			return 0, ErrLongOverflow
		}
		n, err := bdr.r.Read(dest[:])
		if n == 0 {
			return 0, ErrUnexpectedEOF
		} else if err != nil {
			return 0, eofUnexpected(err)
		}
		value |= uint64(dest[0]&0x7F) << uint(7*offset)
		offset++
		if dest[0]&0x80 == 0 {
			break
		}
	}
	return int64((value >> 1) ^ -(value & 1)), nil
}
ReadLong reads a long value. Returns a decoded value and an error if it occurs.
package avro
import (
	"encoding/binary"
	"io"
	"math"
)
type Decoder interface {
	ReadNull() (interface{}, error)
	ReadBoolean() (bool, error)
	ReadInt() (int32, error)
	ReadLong() (int64, error)
	ReadFloat() (float32, error)
	ReadDouble() (float64, error)
	ReadBytes() ([]byte, error)
	ReadString() (string, error)
	ReadEnum() (int32, error)
	ReadArrayStart() (int64, error)
	ArrayNext() (int64, error)
	ReadMapStart() (int64, error)
	MapNext() (int64, error)
	ReadFixed([]byte) error
}
const maxIntBufSize = 5
const maxLongBufSize = 10
type binaryDecoder struct {
	buf []byte
	pos int64
}
type binaryDecoderReader struct {
	r io.Reader
}
func NewBinaryDecoder(buf []byte) Decoder {
	return &binaryDecoder{buf, 0}
}
func NewBinaryDecoderReader(r io.Reader) Decoder {
	return &binaryDecoderReader{
		r: r,
	}
}
func (bd *binaryDecoder) ReadInt() (int32, error) {
	if err := checkEOF(bd.buf, bd.pos, 1); err != nil {
		return 0, ErrUnexpectedEOF
	}
	var value uint32
	var b uint8
	var offset int
	bufLen := int64(len(bd.buf))
	for {
		if offset == maxIntBufSize {
			return 0, ErrIntOverflow
		}
		if bd.pos >= bufLen {
			return 0, ErrUnexpectedEOF
		}
		b = bd.buf[bd.pos]
		value |= uint32(b&0x7F) << uint(7*offset)
		bd.pos++
		offset++
		if b&0x80 == 0 {
			break
		}
	}
	return int32((value >> 1) ^ -(value & 1)), nil
}
func (bdr *binaryDecoderReader) ReadInt() (int32, error) {
	var value uint32
	var offset int
	var dest [1]byte
	for {
		if offset == maxIntBufSize {
			return 0, ErrIntOverflow
		}
		_, err := io.ReadFull(bdr.r, dest[:])
		if err != nil {
			return 0, eofUnexpected(err)
		}
		value |= uint32(dest[0]&0x7F) << uint(7*offset)
		offset++
		if dest[0]&0x80 == 0 {
			break
		}
	}
	return int32((value >> 1) ^ -(value & 1)), nil
}
func (bd *binaryDecoder) ReadLong() (int64, error) {
	var value uint64
	var b uint8
	var offset int
	bufLen := int64(len(bd.buf))
	for {
		if offset == maxLongBufSize {
			return 0, ErrLongOverflow
		}
		if bd.pos >= bufLen {
			return 0, ErrInvalidLong
		}
		b = bd.buf[bd.pos]
		value |= uint64(b&0x7F) << uint(7*offset)
		bd.pos++
		offset++
		if b&0x80 == 0 {
			break
		}
	}
	return int64((value >> 1) ^ -(value & 1)), nil
}