From debe12cfcf9e0672bce0972cc22ff093f215ac59 Mon Sep 17 00:00:00 2001 From: Igor Dolzhikov Date: Sun, 5 Apr 2015 22:32:52 +0600 Subject: [PATCH] net/http, math/big, cmd/internal/gc/big: replaced errors.New(fmt.Sprintf(...)) in favour fmt.Errorf() Change-Id: I38fc0ab84a374cb9be0234e40665d7cea0e76fc1 Reviewed-on: https://go-review.googlesource.com/8402 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/cmd/internal/gc/big/int.go | 3 +-- src/cmd/internal/gc/big/rat.go | 2 +- src/math/big/int.go | 3 +-- src/math/big/rat.go | 2 +- src/net/http/client.go | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/cmd/internal/gc/big/int.go b/src/cmd/internal/gc/big/int.go index 3410ec4729..7b419bf688 100644 --- a/src/cmd/internal/gc/big/int.go +++ b/src/cmd/internal/gc/big/int.go @@ -7,7 +7,6 @@ package big import ( - "errors" "fmt" "io" "math/rand" @@ -813,7 +812,7 @@ func (z *Int) GobDecode(buf []byte) error { } b := buf[0] if b>>1 != intGobVersion { - return errors.New(fmt.Sprintf("Int.GobDecode: encoding version %d not supported", b>>1)) + return fmt.Errorf("Int.GobDecode: encoding version %d not supported", b>>1) } z.neg = b&1 != 0 z.abs = z.abs.setBytes(buf[1:]) diff --git a/src/cmd/internal/gc/big/rat.go b/src/cmd/internal/gc/big/rat.go index 748796c8ca..fb16f18a96 100644 --- a/src/cmd/internal/gc/big/rat.go +++ b/src/cmd/internal/gc/big/rat.go @@ -546,7 +546,7 @@ func (z *Rat) GobDecode(buf []byte) error { } b := buf[0] if b>>1 != ratGobVersion { - return errors.New(fmt.Sprintf("Rat.GobDecode: encoding version %d not supported", b>>1)) + return fmt.Errorf("Rat.GobDecode: encoding version %d not supported", b>>1) } const j = 1 + 4 i := j + binary.BigEndian.Uint32(buf[j-4:j]) diff --git a/src/math/big/int.go b/src/math/big/int.go index 3410ec4729..7b419bf688 100644 --- a/src/math/big/int.go +++ b/src/math/big/int.go @@ -7,7 +7,6 @@ package big import ( - "errors" "fmt" "io" "math/rand" @@ -813,7 +812,7 @@ func (z *Int) GobDecode(buf []byte) error { } b := buf[0] if b>>1 != intGobVersion { - return errors.New(fmt.Sprintf("Int.GobDecode: encoding version %d not supported", b>>1)) + return fmt.Errorf("Int.GobDecode: encoding version %d not supported", b>>1) } z.neg = b&1 != 0 z.abs = z.abs.setBytes(buf[1:]) diff --git a/src/math/big/rat.go b/src/math/big/rat.go index 748796c8ca..fb16f18a96 100644 --- a/src/math/big/rat.go +++ b/src/math/big/rat.go @@ -546,7 +546,7 @@ func (z *Rat) GobDecode(buf []byte) error { } b := buf[0] if b>>1 != ratGobVersion { - return errors.New(fmt.Sprintf("Rat.GobDecode: encoding version %d not supported", b>>1)) + return fmt.Errorf("Rat.GobDecode: encoding version %d not supported", b>>1) } const j = 1 + 4 i := j + binary.BigEndian.Uint32(buf[j-4:j]) diff --git a/src/net/http/client.go b/src/net/http/client.go index 7341871036..88d444eca2 100644 --- a/src/net/http/client.go +++ b/src/net/http/client.go @@ -390,7 +390,7 @@ func (c *Client) doFollowingRedirects(ireq *Request, shouldRedirect func(int) bo } resp.Body.Close() if urlStr = resp.Header.Get("Location"); urlStr == "" { - err = errors.New(fmt.Sprintf("%d response missing Location header", resp.StatusCode)) + err = fmt.Errorf("%d response missing Location header", resp.StatusCode) break } base = req.URL