aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/encoding/binary/varint.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-11-01 22:04:37 -0400
committerRuss Cox <rsc@golang.org>2011-11-01 22:04:37 -0400
commitc2049d2dfeeea3d41fafa91e3e3f0e47c285355b (patch)
tree090fd29206a707cf5a1f63eacaa414203d2b1ccb /src/pkg/encoding/binary/varint.go
parent68050ac76b94b58d962cf8265a8d4eb31ff35658 (diff)
downloadgo-c2049d2dfeeea3d41fafa91e3e3f0e47c285355b.tar.xz
src/pkg/[a-m]*: gofix -r error -force=error
R=golang-dev, iant CC=golang-dev https://golang.org/cl/5322051
Diffstat (limited to 'src/pkg/encoding/binary/varint.go')
-rw-r--r--src/pkg/encoding/binary/varint.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/pkg/encoding/binary/varint.go b/src/pkg/encoding/binary/varint.go
index c98e0e2bf5..d4872eea2c 100644
--- a/src/pkg/encoding/binary/varint.go
+++ b/src/pkg/encoding/binary/varint.go
@@ -25,8 +25,8 @@ package binary
// format incompatible with a varint encoding for larger numbers (say 128-bit).
import (
+ "errors"
"io"
- "os"
)
// MaxVarintLenN is the maximum length of a varint-encoded N-bit integer.
@@ -99,17 +99,17 @@ func Varint(buf []byte) (int64, int) {
}
// WriteUvarint encodes x and writes the result to w.
-func WriteUvarint(w io.Writer, x uint64) os.Error {
+func WriteUvarint(w io.Writer, x uint64) error {
var buf [MaxVarintLen64]byte
n := PutUvarint(buf[:], x)
_, err := w.Write(buf[0:n])
return err
}
-var overflow = os.NewError("binary: varint overflows a 64-bit integer")
+var overflow = errors.New("binary: varint overflows a 64-bit integer")
// ReadUvarint reads an encoded unsigned integer from r and returns it as a uint64.
-func ReadUvarint(r io.ByteReader) (uint64, os.Error) {
+func ReadUvarint(r io.ByteReader) (uint64, error) {
var x uint64
var s uint
for i := 0; ; i++ {
@@ -130,7 +130,7 @@ func ReadUvarint(r io.ByteReader) (uint64, os.Error) {
}
// WriteVarint encodes x and writes the result to w.
-func WriteVarint(w io.Writer, x int64) os.Error {
+func WriteVarint(w io.Writer, x int64) error {
ux := uint64(x) << 1
if x < 0 {
ux = ^ux
@@ -139,7 +139,7 @@ func WriteVarint(w io.Writer, x int64) os.Error {
}
// ReadVarint reads an encoded unsigned integer from r and returns it as a uint64.
-func ReadVarint(r io.ByteReader) (int64, os.Error) {
+func ReadVarint(r io.ByteReader) (int64, error) {
ux, err := ReadUvarint(r) // ok to continue in presence of error
x := int64(ux >> 1)
if ux&1 != 0 {