diff options
| author | Oleksandr Redko <oleksandr.red+github@gmail.com> | 2023-02-12 15:37:00 +0200 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-02-16 23:09:19 +0000 |
| commit | 3ad6393f8676b1b408673bf40b8a876f29561eef (patch) | |
| tree | 7338eaf302fd64d9d24e9776999a919e87c71778 /src/encoding/binary | |
| parent | 135c470b2277e1c9514ba8a5478408fea0dee8a2 (diff) | |
| download | go-3ad6393f8676b1b408673bf40b8a876f29561eef.tar.xz | |
src: rename unexported errors by adding prefix err
By convention, use `err` as prefix for variables of type `error`.
Change-Id: I9401d5d47e994a27be245b2c8b1edd55cdd52db1
Reviewed-on: https://go-review.googlesource.com/c/go/+/467536
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/encoding/binary')
| -rw-r--r-- | src/encoding/binary/varint.go | 6 | ||||
| -rw-r--r-- | src/encoding/binary/varint_test.go | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/encoding/binary/varint.go b/src/encoding/binary/varint.go index 18e1ff1511..7b14fb2b63 100644 --- a/src/encoding/binary/varint.go +++ b/src/encoding/binary/varint.go @@ -123,7 +123,7 @@ func Varint(buf []byte) (int64, int) { return x, n } -var overflow = errors.New("binary: varint overflows a 64-bit integer") +var errOverflow = errors.New("binary: varint overflows a 64-bit integer") // ReadUvarint reads an encoded unsigned integer from r and returns it as a uint64. // The error is EOF only if no bytes were read. @@ -142,14 +142,14 @@ func ReadUvarint(r io.ByteReader) (uint64, error) { } if b < 0x80 { if i == MaxVarintLen64-1 && b > 1 { - return x, overflow + return x, errOverflow } return x | uint64(b)<<s, nil } x |= uint64(b&0x7f) << s s += 7 } - return x, overflow + return x, errOverflow } // ReadVarint reads an encoded signed integer from r and returns it as an int64. diff --git a/src/encoding/binary/varint_test.go b/src/encoding/binary/varint_test.go index a3caea8a43..5c3ea318c3 100644 --- a/src/encoding/binary/varint_test.go +++ b/src/encoding/binary/varint_test.go @@ -212,9 +212,9 @@ func testOverflow(t *testing.T, buf []byte, x0 uint64, n0 int, err0 error) { } func TestOverflow(t *testing.T) { - testOverflow(t, []byte{0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x2}, 0, -10, overflow) - testOverflow(t, []byte{0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x1, 0, 0}, 0, -11, overflow) - testOverflow(t, []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, 1<<64-1, -11, overflow) // 11 bytes, should overflow + testOverflow(t, []byte{0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x2}, 0, -10, errOverflow) + testOverflow(t, []byte{0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x1, 0, 0}, 0, -11, errOverflow) + testOverflow(t, []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, 1<<64-1, -11, errOverflow) // 11 bytes, should overflow } func TestNonCanonicalZero(t *testing.T) { |
