func AsTagAndWireType(v uint64) (tag int32, wireType WireType, err error) {
	wireType = WireType(v & 7)
	tag = int32(v >> 3)
	if tag <= 0 {
		err = ErrBadWireType  
	}
	return
}
AsTagAndWireType converts the given varint in to a field number and wireType

As of now, this function is inlined.  Please double check that any modifications do not modify the
inline eligibility
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
}
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
}
func (cb *Buffer) DecodeFixed64() (x uint64, err error) {
	i := cb.index + 8
	if i < 0 || i > cb.len {
		err = io.ErrUnexpectedEOF
		return
	}
	cb.index = i
	x = uint64(cb.buf[i-8])
	x |= uint64(cb.buf[i-7]) << 8
	x |= uint64(cb.buf[i-6]) << 16
	x |= uint64(cb.buf[i-5]) << 24
	x |= uint64(cb.buf[i-4]) << 32
	x |= uint64(cb.buf[i-3]) << 40
	x |= uint64(cb.buf[i-2]) << 48
	x |= uint64(cb.buf[i-1]) << 56
	return
}
func (cb *Buffer) DecodeFixed32() (x uint64, err error) {
	i := cb.index + 4
	if i < 0 || i > cb.len {
		err = io.ErrUnexpectedEOF
		return
	}
	cb.index = i
	x = uint64(cb.buf[i-4])
	x |= uint64(cb.buf[i-3]) << 8
	x |= uint64(cb.buf[i-2]) << 16
	x |= uint64(cb.buf[i-1]) << 24
	return
}
func DecodeZigZag32(v uint64) int32 {
	return int32((uint32(v) >> 1) ^ uint32((int32(v&1)<<31)>>31))
}
func DecodeZigZag64(v uint64) int64 {
	return int64((v >> 1) ^ uint64((int64(v&1)<<63)>>63))
}
func (cb *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error) {
	n, err := cb.DecodeVarint()
	if err != nil {
		return nil, err
	}
	nb := int(n)
	if nb < 0 {
		return nil, fmt.Errorf("proto: bad byte length %d", nb)
	}
	end := cb.index + nb
	if end < cb.index || end > cb.len {
		return nil, io.ErrUnexpectedEOF
	}
	if !alloc {
		buf = cb.buf[cb.index:end]
		cb.index = end
		return
	}
	buf = make([]byte, nb)
	copy(buf, cb.buf[cb.index:])
	cb.index = end
	return
}
func (cb *Buffer) ReadGroup(alloc bool) ([]byte, error) {
	var groupEnd, dataEnd int
	groupEnd, dataEnd, err := cb.findGroupEnd()
	if err != nil {
		return nil, err
	}
	var results []byte
	if !alloc {
		results = cb.buf[cb.index:dataEnd]
	} else {
		results = make([]byte, dataEnd-cb.index)
		copy(results, cb.buf[cb.index:])
	}
	cb.index = groupEnd
	return results, nil
}
func (cb *Buffer) SkipGroup() error {
	groupEnd, _, err := cb.findGroupEnd()
	if err != nil {
		return err
	}
	cb.index = groupEnd
	return nil
}
func (cb *Buffer) findGroupEnd() (groupEnd int, dataEnd int, err error) {
	bs := cb.buf
	start := cb.index
	defer func() {
		cb.index = start
	}()
	for {
		fieldStart := cb.index
		var v uint64
		v, err = cb.DecodeVarint()
		if err != nil {
			return 0, 0, err
		}
		_, wireType, err := AsTagAndWireType(v)
		if err != nil {
			return 0, 0, err
		}
		switch wireType {
		case WireFixed32:
			if err := cb.Skip(4); err != nil {
				return 0, 0, err
			}
		case WireFixed64:
			if err := cb.Skip(8); err != nil {
				return 0, 0, err
			}
		case WireVarint:
			i := cb.index
			limit := i + 10  
			for {
				if i >= limit {
					return 0, 0, ErrOverflow
				}
				if i >= len(bs) {
					return 0, 0, io.ErrUnexpectedEOF
				}
				if bs[i]&0x80 == 0 {
					break
				}
				i++
			}
			cb.index = i + 1
		case WireBytes:
			l, err := cb.DecodeVarint()
			if err != nil {
				return 0, 0, err
			}
			if err := cb.Skip(int(l)); err != nil {
				return 0, 0, err
			}
		case WireStartGroup:
			if err := cb.SkipGroup(); err != nil {
				return 0, 0, err
			}
		case WireEndGroup:
			return cb.index, fieldStart, nil
		default:
			return 0, 0, ErrBadWireType
		}
	}
}