func (p *Buffer) DecodeVarint() (x uint64, err error) {
	i := p.index
	l := len(p.buf)
	for shift := uint(0); ; shift += 7 {
		if i >= l {
			err = io.ErrUnexpectedEOF
			return
		}
		b := p.buf[i]
		i++
		x |= (uint64(b) & 0x7F) << shift
		if b < 0x80 {
			break
		}
	}
	p.index = i
	return
}
DecodeVarint reads a varint-encoded integer from the Buffer.
This is the format for the
int32, int64, uint32, uint64, bool, and enum
protocol buffer types.
package proto
import (
	"errors"
	"fmt"
	"io"
	"os"
	"reflect"
	"runtime"
	"unsafe"
)
var ErrWrongType = errors.New("field/encoding mismatch: wrong type for field")
func DecodeVarint(buf []byte) (x uint64, n int) {
	for shift := uint(0); ; shift += 7 {
		if n >= len(buf) {
			return 0, 0
		}
		b := uint64(buf[n])
		n++
		x |= (b & 0x7F) << shift
		if (b & 0x80) == 0 {
			break
		}
	}
	return x, n
}