func readVarInt64(r io.Reader) (int64, error) {
	// Since we are being given seven bits per byte, we can fit 9 1/8 bytes
	// of input into our eight bytes of value, so don't read more than 10 bytes.
	bits, err := readVarNumber(10, r)
	if err != nil {
		return 0, err
	}

	// 0xFE == 0b1111_1110.
	if (len(bits) == 10) && (bits[9]&0xFE != 0) {
		return 0, errors.Errorf("number is too big to fit into int64: % #x", bits)
	}

	var ret int64
	// Compact all of the bits into an int64, ignoring the stop bit.
	// Turn [0111 1111] [1110 1111] into [0011 1111] [1110 1111].
	for i, b := range bits {
		ret <<= 7
		// Need to ignore the sign bit.  We add the sign later.
		if i == 0 {
			ret |= int64(b & 0x3F)
		} else {
			ret |= int64(b & 0x7F)
		}
	}

	// The second bit of the number is the sign bit.
	if bits[0]&0x40 != 0 {
		ret *= -1
	}

	return ret, nil
}
// readVarInt64 reads until the high bit is set, which signals the end of the
// variable-length number, or we hit the maximum number of bytes for int64.
// We compress the number into an int64.
readVarInt64 reads until the high bit is set, which signals the end of the
variable-length number, or we hit the maximum number of bytes for int64.
We compress the number into an int64.
// readVarInt64 reads until the high bit is set which signals the end of the // variable - length number or we hit the maximum number of bytes for int64 . // We compress the number into an int64 .
func readVarInt64(r io.Reader) (int64, error) {
	bits, err := readVarNumber(10, r)
	if err != nil {
		return 0, err
	}
	if (len(bits) == 10) && (bits[9]&0xFE != 0) {
		return 0, errors.Errorf("number is too big to fit into int64: % #x", bits)
	}
	var ret int64
	for i, b := range bits {
		ret <<= 7
		if i == 0 {
			ret |= int64(b & 0x3F)
		} else {
			ret |= int64(b & 0x7F)
		}
	}
	if bits[0]&0x40 != 0 {
		ret *= -1
	}
	return ret, nil
}
func readVarInt64 ( r io . Reader ) ( int64 , error ) { bits , err := readVarNumber ( 10 , r ) if err != nil { return 0 , err } if ( len ( bits ) == 10 ) && ( bits [ 9 ] & 0xFE != 0 ) { return 0 , errors . Errorf ( " " , bits ) } var ret int64 for i , b := range bits { ret <<= 7 if i == 0 { ret |= int64 ( b & 0x3F ) } else { ret |= int64 ( b & 0x7F ) } } if bits [ 0 ] & 0x40 != 0 { ret *= - 1 } return ret , nil }
readVarInt64 reads until the high bit is set, which signals the end of the
variable-length number, or we hit the maximum number of bytes for int64.
readVarInt64 reads until the high bit is set which signals the end of the variable - length number or we hit the maximum number of bytes for int64 .
// Since we are being given seven bits per byte, we can fit 9 1/8 bytes // of input into our eight bytes of value, so don't read more than 10 bytes. // 0xFE == 0b1111_1110. // Compact all of the bits into an int64, ignoring the stop bit. // Turn [0111 1111] [1110 1111] into [0011 1111] [1110 1111]. // Need to ignore the sign bit.  We add the sign later. // The second bit of the number is the sign bit.