From 3ad6393f8676b1b408673bf40b8a876f29561eef Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Sun, 12 Feb 2023 15:37:00 +0200 Subject: [PATCH] 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 Reviewed-by: Robert Griesemer TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor --- src/encoding/binary/varint.go | 6 +++--- src/encoding/binary/varint_test.go | 6 +++--- src/fmt/scan.go | 14 ++++++------ src/time/format.go | 4 ++-- src/time/zoneinfo_plan9.go | 8 +++---- src/time/zoneinfo_read.go | 34 +++++++++++++++--------------- 6 files changed, 36 insertions(+), 36 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)< 0 { - return 0, atoiError + return 0, errAtoi } if neg { x = -x diff --git a/src/time/zoneinfo_plan9.go b/src/time/zoneinfo_plan9.go index 5d432fe297..d13b623a37 100644 --- a/src/time/zoneinfo_plan9.go +++ b/src/time/zoneinfo_plan9.go @@ -56,7 +56,7 @@ func loadZoneDataPlan9(s string) (l *Location, err error) { if len(f) == 2 && f[0] == "GMT" { return UTC, nil } - return nil, badData + return nil, errBadData } var zones [2]zone @@ -64,14 +64,14 @@ func loadZoneDataPlan9(s string) (l *Location, err error) { // standard timezone offset o, err := atoi(f[1]) if err != nil { - return nil, badData + return nil, errBadData } zones[0] = zone{name: f[0], offset: o, isDST: false} // alternate timezone offset o, err = atoi(f[3]) if err != nil { - return nil, badData + return nil, errBadData } zones[1] = zone{name: f[2], offset: o, isDST: true} @@ -85,7 +85,7 @@ func loadZoneDataPlan9(s string) (l *Location, err error) { } t, err := atoi(f[i]) if err != nil { - return nil, badData + return nil, errBadData } t -= zones[0].offset tx = append(tx, zoneTrans{when: int64(t), index: uint8(zi)}) diff --git a/src/time/zoneinfo_read.go b/src/time/zoneinfo_read.go index 90814ad36a..d8b35003a1 100644 --- a/src/time/zoneinfo_read.go +++ b/src/time/zoneinfo_read.go @@ -107,7 +107,7 @@ func byteString(p []byte) string { return string(p) } -var badData = errors.New("malformed time zone information") +var errBadData = errors.New("malformed time zone information") // LoadLocationFromTZData returns a Location with the given name // initialized from the IANA Time Zone database-formatted data. @@ -118,14 +118,14 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { // 4-byte magic "TZif" if magic := d.read(4); string(magic) != "TZif" { - return nil, badData + return nil, errBadData } // 1-byte version, then 15 bytes of padding var version int var p []byte if p = d.read(16); len(p) != 16 { - return nil, badData + return nil, errBadData } else { switch p[0] { case 0: @@ -135,7 +135,7 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { case '3': version = 3 default: - return nil, badData + return nil, errBadData } } @@ -158,10 +158,10 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { for i := 0; i < 6; i++ { nn, ok := d.big4() if !ok { - return nil, badData + return nil, errBadData } if uint32(int(nn)) != nn { - return nil, badData + return nil, errBadData } n[i] = int(nn) } @@ -191,10 +191,10 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { for i := 0; i < 6; i++ { nn, ok := d.big4() if !ok { - return nil, badData + return nil, errBadData } if uint32(int(nn)) != nn { - return nil, badData + return nil, errBadData } n[i] = int(nn) } @@ -229,7 +229,7 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { isutc := d.read(n[NUTCLocal]) if d.error { // ran out of data - return nil, badData + return nil, errBadData } var extend string @@ -245,26 +245,26 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { if nzone == 0 { // Reject tzdata files with no zones. There's nothing useful in them. // This also avoids a panic later when we add and then use a fake transition (golang.org/issue/29437). - return nil, badData + return nil, errBadData } zones := make([]zone, nzone) for i := range zones { var ok bool var n uint32 if n, ok = zonedata.big4(); !ok { - return nil, badData + return nil, errBadData } if uint32(int(n)) != n { - return nil, badData + return nil, errBadData } zones[i].offset = int(int32(n)) var b byte if b, ok = zonedata.byte(); !ok { - return nil, badData + return nil, errBadData } zones[i].isDST = b != 0 if b, ok = zonedata.byte(); !ok || int(b) >= len(abbrev) { - return nil, badData + return nil, errBadData } zones[i].name = byteString(abbrev[b:]) if runtime.GOOS == "aix" && len(name) > 8 && (name[:8] == "Etc/GMT+" || name[:8] == "Etc/GMT-") { @@ -283,20 +283,20 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { var n int64 if !is64 { if n4, ok := txtimes.big4(); !ok { - return nil, badData + return nil, errBadData } else { n = int64(int32(n4)) } } else { if n8, ok := txtimes.big8(); !ok { - return nil, badData + return nil, errBadData } else { n = int64(n8) } } tx[i].when = n if int(txzones[i]) >= len(zones) { - return nil, badData + return nil, errBadData } tx[i].index = txzones[i] if i < len(isstd) { -- 2.50.0