1
0
mirror of https://github.com/golang/go synced 2024-11-22 20:04:47 -07:00

encoding/binary: ReadVarint reads a signed number, not unsigned number

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6762051
This commit is contained in:
Shenghou Ma 2012-10-26 21:14:34 +08:00
parent 067315c647
commit f9902c7197

View File

@ -123,7 +123,7 @@ func ReadUvarint(r io.ByteReader) (uint64, error) {
panic("unreachable")
}
// ReadVarint reads an encoded unsigned integer from r and returns it as an int64.
// ReadVarint reads an encoded signed integer from r and returns it as an int64.
func ReadVarint(r io.ByteReader) (int64, error) {
ux, err := ReadUvarint(r) // ok to continue in presence of error
x := int64(ux >> 1)