func (cb *Buffer) DecodeVarint() (uint64, error) {
	if cb.len == 0 {
		return 0, io.ErrUnexpectedEOF
	}
	const (
		step = 7
		bit  = 1 << 7
		mask = bit - 1
	)
	if cb.len >= 10 {
		b := cb.buf[cb.index]
		if b < bit {
			cb.index++
			return uint64(b), nil
		}
		x := uint64(b & mask)
		var s uint = step
		b = cb.buf[cb.index+1]
		if b < bit {
			cb.index += 2
			return x | uint64(b)<<s, nil
		}
		x |= uint64(b&mask) << s
		s += step
		b = cb.buf[cb.index+2]
		if b < bit {
			cb.index += 3
			return x | uint64(b)<<s, nil
		}
		x |= uint64(b&mask) << s
		s += step
		b = cb.buf[cb.index+3]
		if b < bit {
			cb.index += 4
			return x | uint64(b)<<s, nil
		}
		x |= uint64(b&mask) << s
		s += step
		b = cb.buf[cb.index+4]
		if b < bit {
			cb.index += 5
			return x | uint64(b)<<s, nil
		}
		x |= uint64(b&mask) << s
		s += step
		b = cb.buf[cb.index+5]
		if b < bit {
			cb.index += 6
			return x | uint64(b)<<s, nil
		}
		x |= uint64(b&mask) << s
		s += step
		b = cb.buf[cb.index+6]
		if b < bit {
			cb.index += 7
			return x | uint64(b)<<s, nil
		}
		x |= uint64(b&mask) << s
		s += step
		b = cb.buf[cb.index+7]
		if b < bit {
			cb.index += 8
			return x | uint64(b)<<s, nil
		}
		x |= uint64(b&mask) << s
		s += step
		b = cb.buf[cb.index+8]
		if b < bit {
			cb.index += 9
			return x | uint64(b)<<s, nil
		}
		x |= uint64(b&mask) << s
		s += step
		b = cb.buf[cb.index+9]
		if b < bit {
			if b > 1 {
				return 0, ErrOverflow
			}
			cb.index += 10
			return x | uint64(b)<<s, nil
		} else if cb.len == 10 {
			return 0, io.ErrUnexpectedEOF
		}
		for _, b := range cb.buf[cb.index+10:] {
			if b < bit {
				return 0, ErrOverflow
			}
		}
		return 0, io.ErrUnexpectedEOF
	}
	b := cb.buf[cb.index]
	if b < bit {
		cb.index++
		return uint64(b), nil
	} else if cb.len == 1 {
		return 0, io.ErrUnexpectedEOF
	}
	x := uint64(b & mask)
	var s uint = step
	b = cb.buf[cb.index+1]
	if b < bit {
		cb.index += 2
		return x | uint64(b)<<s, nil
	} else if cb.len == 2 {
		return 0, io.ErrUnexpectedEOF
	}
	x |= uint64(b&mask) << s
	s += step
	b = cb.buf[cb.index+2]
	if b < bit {
		cb.index += 3
		return x | uint64(b)<<s, nil
	} else if cb.len == 3 {
		return 0, io.ErrUnexpectedEOF
	}
	x |= uint64(b&mask) << s
	s += step
	b = cb.buf[cb.index+3]
	if b < bit {
		cb.index += 4
		return x | uint64(b)<<s, nil
	} else if cb.len == 4 {
		return 0, io.ErrUnexpectedEOF
	}
	x |= uint64(b&mask) << s
	s += step
	b = cb.buf[cb.index+4]
	if b < bit {
		cb.index += 5
		return x | uint64(b)<<s, nil
	} else if cb.len == 5 {
		return 0, io.ErrUnexpectedEOF
	}
	x |= uint64(b&mask) << s
	s += step
	b = cb.buf[cb.index+5]
	if b < bit {
		cb.index += 6
		return x | uint64(b)<<s, nil
	} else if cb.len == 6 {
		return 0, io.ErrUnexpectedEOF
	}
	x |= uint64(b&mask) << s
	s += step
	b = cb.buf[cb.index+6]
	if b < bit {
		cb.index += 7
		return x | uint64(b)<<s, nil
	} else if cb.len == 7 {
		return 0, io.ErrUnexpectedEOF
	}
	x |= uint64(b&mask) << s
	s += step
	b = cb.buf[cb.index+7]
	if b < bit {
		cb.index += 8
		return x | uint64(b)<<s, nil
	} else if cb.len == 8 {
		return 0, io.ErrUnexpectedEOF
	}
	x |= uint64(b&mask) << s
	s += step
	b = cb.buf[cb.index+8]
	if b < bit {
		cb.index += 9
		return x | uint64(b)<<s, nil
	} else if cb.len == 9 {
		return 0, io.ErrUnexpectedEOF
	}
	x |= uint64(b&mask) << s
	s += step
	b = cb.buf[cb.index+9]
	if b < bit {
		if b > 1 {
			return 0, ErrOverflow
		}
		cb.index += 10
		return x | uint64(b)<<s, nil
	} else if cb.len == 10 {
		return 0, io.ErrUnexpectedEOF
	}
	for _, b := range cb.buf[cb.index+10:] {
		if b < bit {
			return 0, ErrOverflow
		}
	}
	return 0, io.ErrUnexpectedEOF
}
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.

This implementation is inlined from https://github.com/dennwc/varint to avoid the call-site overhead
package codec
import (
	"errors"
	"fmt"
	"io"
)
var ErrOverflow = errors.New("proto: integer overflow")
var ErrBadWireType = errors.New("proto: bad wiretype")
var varintTypes = map[FieldType]bool{}
var fixed32Types = map[FieldType]bool{}
var fixed64Types = map[FieldType]bool{}
func init() {
	varintTypes[FieldType_BOOL] = true
	varintTypes[FieldType_INT32] = true
	varintTypes[FieldType_INT64] = true
	varintTypes[FieldType_UINT32] = true
	varintTypes[FieldType_UINT64] = true
	varintTypes[FieldType_SINT32] = true
	varintTypes[FieldType_SINT64] = true
	varintTypes[FieldType_ENUM] = true
	fixed32Types[FieldType_FIXED32] = true
	fixed32Types[FieldType_SFIXED32] = true
	fixed32Types[FieldType_FLOAT] = true
	fixed64Types[FieldType_FIXED64] = true
	fixed64Types[FieldType_SFIXED64] = true
	fixed64Types[FieldType_DOUBLE] = true
}