packagecid// Version of varint function that work with a string rather than// []byte to avoid unnecessary allocation// Copyright 2011 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license as given at https://golang.org/LICENSE// uvarint decodes a uint64 from buf and returns that value and the// number of characters read (> 0). If an error occurred, the value is 0// and the number of bytes n is <= 0 meaning://// n == 0: buf too small// n < 0: value larger than 64 bits (overflow)// and -n is the number of bytes read//funcuvarint(bufstring)(uint64,int){varxuint64varsuint// we have a binary string so we can't use a range loopefori:=0;i<len(buf);i++{b:=buf[i]ifb<0x80{ifi>9||i==9&&b>1{return0,-(i+1)// overflow}returnx|uint64(b)<<s,i+1}x|=uint64(b&0x7f)<<ss+=7}return0,0}