[go] all: replace superflous fmt.Errorf with errors.New

107 views
Skip to first unread message

Emmanuel Odeke (Gerrit)

unread,
May 4, 2022, 1:17:07 AM5/4/22
to Ian Lance Taylor, Rob Pike, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Attention is currently required from: Ian Lance Taylor, Rob Pike.

Emmanuel Odeke would like Ian Lance Taylor and Rob Pike to review this change.

View Change

all: replace superflous fmt.Errorf with errors.New

Mostly automated changes by running a quick search and replace
tool from Orijtech Inc for matching the target pattern as per
https://github.com/orijtech/otils/tree/master/fmterrorffix

The missing imports were added by hand then ./all.bash was run
to ensure the builds and tests pass.

Updates #52696

Change-Id: I660d15676d02b87aad82730f849ed866167d8c50
---
M misc/cgo/testshared/shared_test.go
M misc/cgo/testsigfwd/main.go
M src/archive/tar/common.go
M src/archive/tar/reader_test.go
M src/cmd/compile/internal/importer/exportdata.go
M src/cmd/compile/internal/ssa/poset.go
M src/cmd/compile/internal/ssa/stmtlines_test.go
M src/cmd/compile/internal/staticdata/data.go
M src/cmd/compile/internal/types/goversion.go
M src/cmd/compile/internal/types2/check_test.go
M src/cmd/compile/internal/types2/resolver.go
M src/cmd/compile/internal/types2/version.go
M src/cmd/cover/cover.go
M src/cmd/dist/buildtag_test.go
M src/cmd/dist/test.go
M src/cmd/go/internal/cache/cache.go
M src/cmd/go/internal/cache/default.go
M src/cmd/go/internal/cfg/cfg.go
M src/cmd/go/internal/fsys/fsys.go
M src/cmd/go/internal/generate/generate.go
M src/cmd/go/internal/get/get.go
M src/cmd/go/internal/imports/scan.go
M src/cmd/go/internal/load/flag.go
M src/cmd/go/internal/load/pkg.go
M src/cmd/go/internal/modfetch/cache.go
M src/cmd/go/internal/modfetch/codehost/codehost.go
M src/cmd/go/internal/modfetch/codehost/git.go
M src/cmd/go/internal/modfetch/coderepo.go
M src/cmd/go/internal/modfetch/proxy.go
M src/cmd/go/internal/modfetch/sumdb.go
M src/cmd/go/internal/modget/get.go
M src/cmd/go/internal/modload/init.go
M src/cmd/go/internal/test/testflag.go
M src/cmd/go/internal/vcs/vcs.go
M src/cmd/go/internal/web/http.go
M src/cmd/go/internal/work/exec.go
M src/cmd/go/internal/work/gc.go
M src/cmd/go/internal/work/gccgo.go
M src/cmd/gofmt/gofmt.go
M src/cmd/internal/archive/archive.go
M src/cmd/internal/buildid/buildid.go
M src/cmd/internal/buildid/note.go
M src/cmd/internal/buildid/rewrite.go
M src/cmd/internal/obj/riscv/obj.go
M src/cmd/internal/objfile/disasm.go
M src/cmd/internal/objfile/elf.go
M src/cmd/internal/objfile/goobj.go
M src/cmd/internal/objfile/macho.go
M src/cmd/internal/objfile/pe.go
M src/cmd/internal/objfile/plan9obj.go
M src/cmd/internal/objfile/xcoff.go
M src/cmd/internal/osinfo/os_js.go
M src/cmd/link/internal/ld/macho.go
M src/cmd/link/internal/ld/macho_combine_dwarf.go
M src/cmd/link/internal/loadelf/ldelf.go
M src/cmd/pprof/pprof.go
M src/cmd/trace/annotations.go
M src/cmd/vet/testdata/unused/unused.go
M src/cmd/vet/vet_test.go
M src/compress/flate/deflate_test.go
M src/crypto/tls/auth.go
M src/crypto/tls/handshake_client_test.go
M src/crypto/tls/handshake_server_test.go
M src/crypto/tls/prf.go
M src/crypto/x509/parser.go
M src/crypto/x509/verify_test.go
M src/database/sql/convert_test.go
M src/database/sql/driver/types.go
M src/debug/buildinfo/buildinfo.go
M src/debug/pe/file.go
M src/debug/pe/symbol.go
M src/encoding/asn1/marshal.go
M src/encoding/gob/gobencdec_test.go
M src/encoding/json/decode_test.go
M src/encoding/xml/marshal.go
M src/encoding/xml/xml_test.go
M src/flag/flag_test.go
M src/go/doc/doc.go
M src/go/internal/gccgoimporter/ar.go
M src/go/internal/gcimporter/exportdata.go
M src/go/types/check_test.go
M src/go/types/resolver.go
M src/go/types/version.go
M src/html/template/template.go
M src/image/gif/reader.go
M src/internal/buildcfg/cfg.go
M src/internal/buildcfg/exp.go
M src/internal/fuzz/encoding.go
M src/internal/fuzz/sys_posix.go
M src/internal/fuzz/sys_windows.go
M src/internal/fuzz/worker.go
M src/internal/profile/merge.go
M src/internal/profile/profile.go
M src/internal/testenv/testenv.go
M src/internal/trace/order.go
M src/internal/trace/parser.go
M src/internal/xcoff/ar.go
M src/internal/xcoff/file.go
M src/io/io_test.go
M src/math/big/floatconv.go
M src/mime/multipart/multipart.go
M src/net/dnsclient_unix_test.go
M src/net/http/client_test.go
M src/net/http/clientserver_test.go
M src/net/http/h2_bundle.go
M src/net/http/httputil/reverseproxy.go
M src/net/http/httputil/reverseproxy_test.go
M src/net/http/internal/chunked_test.go
M src/net/http/request.go
M src/net/http/serve_test.go
M src/net/sendfile_test.go
M src/net/textproto/reader.go
M src/net/url/url.go
M src/runtime/debug/mod.go
M src/runtime/malloc_test.go
M src/runtime/pprof/pprof.go
M src/runtime/pprof/pprof_test.go
M src/runtime/pprof/proto.go
M src/runtime/race/race_test.go
M src/runtime/syscall_windows_test.go
M src/runtime/testdata/testprog/numcpu_freebsd.go
M src/strings/replace_test.go
M src/testing/benchmark.go
M src/text/template/funcs.go
M src/text/template/helper.go
M src/time/zoneinfo_test.go
M test/heapsampling.go
M test/run.go
M test/typeparam/issue48185b.dir/main.go
129 files changed, 390 insertions(+), 313 deletions(-)

diff --git a/misc/cgo/testshared/shared_test.go b/misc/cgo/testshared/shared_test.go
index b78083b..49c90ca 100644
--- a/misc/cgo/testshared/shared_test.go
+++ b/misc/cgo/testshared/shared_test.go
@@ -189,7 +189,7 @@
func cloneGOROOTDeps(goroot string) error {
oldGOROOT := strings.TrimSpace(goCmd(nil, "env", "GOROOT"))
if oldGOROOT == "" {
- return fmt.Errorf("go env GOROOT returned an empty string")
+ return errors.New("go env GOROOT returned an empty string")
}

// Before we clone GOROOT, figure out which packages we need to copy over.
diff --git a/misc/cgo/testsigfwd/main.go b/misc/cgo/testsigfwd/main.go
index 6d97050..56d470a 100644
--- a/misc/cgo/testsigfwd/main.go
+++ b/misc/cgo/testsigfwd/main.go
@@ -93,7 +93,7 @@
func f() (ret bool) {
defer func() {
if recover() == nil {
- fmt.Errorf("ERROR: couldn't raise SIGSEGV in Go.")
+ errors.New("ERROR: couldn't raise SIGSEGV in Go.")
C.exit(2)
}
ret = true
@@ -105,7 +105,7 @@
func main() {
// Test that the signal originating in Go is handled (and recovered) by Go.
if !f() {
- fmt.Errorf("couldn't recover from SIGSEGV in Go.")
+ errors.New("couldn't recover from SIGSEGV in Go.")
C.exit(2)
}

diff --git a/src/archive/tar/common.go b/src/archive/tar/common.go
index c99b5c1..44e6ae2 100644
--- a/src/archive/tar/common.go
+++ b/src/archive/tar/common.go
@@ -655,7 +655,7 @@
case fm&fs.ModeNamedPipe != 0:
h.Typeflag = TypeFifo
case fm&fs.ModeSocket != 0:
- return nil, fmt.Errorf("archive/tar: sockets not supported")
+ return nil, errors.New("archive/tar: sockets not supported")
default:
return nil, fmt.Errorf("archive/tar: unknown file mode %v", fm)
}
diff --git a/src/archive/tar/reader_test.go b/src/archive/tar/reader_test.go
index f21a606..8cb68e1 100644
--- a/src/archive/tar/reader_test.go
+++ b/src/archive/tar/reader_test.go
@@ -759,7 +759,7 @@
type readSeeker struct{ io.ReadSeeker }
type readBadSeeker struct{ io.ReadSeeker }

-func (rbs *readBadSeeker) Seek(int64, int) (int64, error) { return 0, fmt.Errorf("illegal seek") }
+func (rbs *readBadSeeker) Seek(int64, int) (int64, error) { return 0, errors.New("illegal seek") }

// TestReadTruncation test the ending condition on various truncated files and
// that truncated files are still detected even if the underlying io.Reader
diff --git a/src/cmd/compile/internal/importer/exportdata.go b/src/cmd/compile/internal/importer/exportdata.go
index 42fc5c9..3229808 100644
--- a/src/cmd/compile/internal/importer/exportdata.go
+++ b/src/cmd/compile/internal/importer/exportdata.go
@@ -8,6 +8,7 @@

import (
"bufio"
+ "errors"
"fmt"
"io"
"strconv"
@@ -28,7 +29,7 @@
s := strings.TrimSpace(string(hdr[16+12+6+6+8:][:10]))
size, err = strconv.Atoi(s)
if err != nil || hdr[len(hdr)-2] != '`' || hdr[len(hdr)-1] != '\n' {
- err = fmt.Errorf("invalid archive header")
+ err = errors.New("invalid archive header")
return
}
name = strings.TrimSpace(string(hdr[:16]))
@@ -60,7 +61,7 @@

// First entry should be __.PKGDEF.
if name != "__.PKGDEF" {
- err = fmt.Errorf("go archive is missing __.PKGDEF")
+ err = errors.New("go archive is missing __.PKGDEF")
return
}

@@ -75,7 +76,7 @@
// Now at __.PKGDEF in archive or still at beginning of file.
// Either way, line should begin with "go object ".
if !strings.HasPrefix(string(line), "go object ") {
- err = fmt.Errorf("not a Go object file")
+ err = errors.New("not a Go object file")
return
}
size -= len(line)
diff --git a/src/cmd/compile/internal/ssa/poset.go b/src/cmd/compile/internal/ssa/poset.go
index ee884ca..f9276fe 100644
--- a/src/cmd/compile/internal/ssa/poset.go
+++ b/src/cmd/compile/internal/ssa/poset.go
@@ -5,6 +5,7 @@
package ssa

import (
+ "errors"
"fmt"
"os"
)
@@ -812,7 +813,7 @@
for _, bs := range po.noneq {
for _, x := range bs {
if x != 0 {
- return fmt.Errorf("non-empty noneq map")
+ return errors.New("non-empty noneq map")
}
}
}
diff --git a/src/cmd/compile/internal/ssa/stmtlines_test.go b/src/cmd/compile/internal/ssa/stmtlines_test.go
index 088f980..79ee180 100644
--- a/src/cmd/compile/internal/ssa/stmtlines_test.go
+++ b/src/cmd/compile/internal/ssa/stmtlines_test.go
@@ -7,7 +7,7 @@
"debug/elf"
"debug/macho"
"debug/pe"
- "fmt"
+ "errors"
"internal/testenv"
"internal/xcoff"
"io"
@@ -34,7 +34,7 @@
return fh.DWARF()
}

- return nil, fmt.Errorf("unrecognized executable format")
+ return nil, errors.New("unrecognized executable format")
}

func must(err error) {
diff --git a/src/cmd/compile/internal/staticdata/data.go b/src/cmd/compile/internal/staticdata/data.go
index b114bb2..2f8a1f7 100644
--- a/src/cmd/compile/internal/staticdata/data.go
+++ b/src/cmd/compile/internal/staticdata/data.go
@@ -6,6 +6,7 @@

import (
"crypto/sha256"
+ "errors"
"fmt"
"go/constant"
"io"
@@ -113,7 +114,7 @@
return nil, 0, err
}
if !info.Mode().IsRegular() {
- return nil, 0, fmt.Errorf("not a regular file")
+ return nil, 0, errors.New("not a regular file")
}
size := info.Size()
if size <= 1*1024 {
@@ -122,7 +123,7 @@
return nil, 0, err
}
if int64(len(data)) != size {
- return nil, 0, fmt.Errorf("file changed between reads")
+ return nil, 0, errors.New("file changed between reads")
}
var sym *obj.LSym
if readonly {
@@ -154,7 +155,7 @@
return nil, 0, err
}
if n != size {
- return nil, 0, fmt.Errorf("file changed between reads")
+ return nil, 0, errors.New("file changed between reads")
}
sum = h.Sum(nil)
copy(hash, sum)
diff --git a/src/cmd/compile/internal/types/goversion.go b/src/cmd/compile/internal/types/goversion.go
index ceb2ed3..ec76ea2 100644
--- a/src/cmd/compile/internal/types/goversion.go
+++ b/src/cmd/compile/internal/types/goversion.go
@@ -5,6 +5,7 @@
package types

import (
+ "errors"
"fmt"
"internal/goversion"
"log"
@@ -61,7 +62,7 @@
func parseLang(s string) (lang, error) {
matches := goVersionRE.FindStringSubmatch(s)
if matches == nil {
- return lang{}, fmt.Errorf(`should be something like "go1.12"`)
+ return lang{}, errors.New(`should be something like "go1.12"`)
}
major, err := strconv.Atoi(matches[1])
if err != nil {
diff --git a/src/cmd/compile/internal/types2/check_test.go b/src/cmd/compile/internal/types2/check_test.go
index ec242c5..bc216a0 100644
--- a/src/cmd/compile/internal/types2/check_test.go
+++ b/src/cmd/compile/internal/types2/check_test.go
@@ -25,8 +25,8 @@
import (
"bytes"
"cmd/compile/internal/syntax"
+ "errors"
"flag"
- "fmt"
"internal/testenv"
"os"
"path/filepath"
@@ -116,7 +116,7 @@
}
end := bytes.Index(src, []byte("\n"))
if end < 0 || end > maxLen {
- return fmt.Errorf("flags comment line too long")
+ return errors.New("flags comment line too long")
}

return flags.Parse(strings.Fields(string(src[:end])))
diff --git a/src/cmd/compile/internal/types2/resolver.go b/src/cmd/compile/internal/types2/resolver.go
index 5c64ecd..5866e3f 100644
--- a/src/cmd/compile/internal/types2/resolver.go
+++ b/src/cmd/compile/internal/types2/resolver.go
@@ -6,6 +6,7 @@

import (
"cmd/compile/internal/syntax"
+ "errors"
"fmt"
"go/constant"
"sort"
@@ -72,7 +73,7 @@
return "", err
}
if s == "" {
- return "", fmt.Errorf("empty string")
+ return "", errors.New("empty string")
}
const illegalChars = `!"#$%&'()*,:;<=>?[\]^{|}` + "`\uFFFD"
for _, r := range s {
@@ -139,7 +140,7 @@
// ordinary import
var err error
if importer := check.conf.Importer; importer == nil {
- err = fmt.Errorf("Config.Importer not installed")
+ err = errors.New("Config.Importer not installed")
} else if importerFrom, ok := importer.(ImporterFrom); ok {
imp, err = importerFrom.ImportFrom(path, dir, 0)
if imp == nil && err == nil {
diff --git a/src/cmd/compile/internal/types2/version.go b/src/cmd/compile/internal/types2/version.go
index b649f09..e7eeedd 100644
--- a/src/cmd/compile/internal/types2/version.go
+++ b/src/cmd/compile/internal/types2/version.go
@@ -6,7 +6,7 @@

import (
"cmd/compile/internal/syntax"
- "fmt"
+ "errors"
"regexp"
"strconv"
"strings"
@@ -66,7 +66,7 @@
}
matches := goVersionRx.FindStringSubmatch(s)
if matches == nil {
- err = fmt.Errorf(`should be something like "go1.12"`)
+ err = errors.New(`should be something like "go1.12"`)
return
}
v.major, err = strconv.Atoi(matches[1])
diff --git a/src/cmd/cover/cover.go b/src/cmd/cover/cover.go
index 9c8529f..59a7085 100644
--- a/src/cmd/cover/cover.go
+++ b/src/cmd/cover/cover.go
@@ -6,6 +6,7 @@

import (
"bytes"
+ "errors"
"flag"
"fmt"
"go/ast"
@@ -105,14 +106,14 @@
profile = *htmlOut
if *funcOut != "" {
if profile != "" {
- return fmt.Errorf("too many options")
+ return errors.New("too many options")
}
profile = *funcOut
}

// Must either display a profile or rewrite Go source.
if (profile == "") == (*mode == "") {
- return fmt.Errorf("too many options")
+ return errors.New("too many options")
}

if *varVar != "" && !token.IsIdentifier(*varVar) {
@@ -132,14 +133,14 @@
}

if flag.NArg() == 0 {
- return fmt.Errorf("missing source file")
+ return errors.New("missing source file")
} else if flag.NArg() == 1 {
return nil
}
} else if flag.NArg() == 0 {
return nil
}
- return fmt.Errorf("too many arguments")
+ return errors.New("too many arguments")
}

// Block represents the information about a basic block to be recorded in the analysis.
diff --git a/src/cmd/dist/buildtag_test.go b/src/cmd/dist/buildtag_test.go
index f64abfd..109cdaa 100644
--- a/src/cmd/dist/buildtag_test.go
+++ b/src/cmd/dist/buildtag_test.go
@@ -5,7 +5,7 @@
package main

import (
- "fmt"
+ "errors"
"reflect"
"testing"
)
@@ -27,10 +27,10 @@
{"!(!(!(gccgo || gc)))", false, nil},
{"compiler_bootstrap", false, nil},
{"cmd_go_bootstrap", true, nil},
- {"syntax(error", false, fmt.Errorf("parsing //go:build line: unexpected (")},
- {"(gc", false, fmt.Errorf("parsing //go:build line: missing )")},
- {"gc gc", false, fmt.Errorf("parsing //go:build line: unexpected tag")},
- {"(gc))", false, fmt.Errorf("parsing //go:build line: unexpected )")},
+ {"syntax(error", false, errors.New("parsing //go:build line: unexpected (")},
+ {"(gc", false, errors.New("parsing //go:build line: missing )")},
+ {"gc gc", false, errors.New("parsing //go:build line: unexpected tag")},
+ {"(gc))", false, errors.New("parsing //go:build line: unexpected )")},
}

func TestBuildParser(t *testing.T) {
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index a540a2a..eda8856 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -6,6 +6,7 @@

import (
"bytes"
+ "errors"
"flag"
"fmt"
"io/ioutil"
@@ -1104,7 +1105,7 @@

parts := strings.Split(string(out), "\n")
if len(parts) < 2 {
- return fmt.Errorf("'go env GOEXE GOTMPDIR' output contains <2 lines")
+ return errors.New("'go env GOEXE GOTMPDIR' output contains <2 lines")
}
GOEXE := strings.TrimSpace(parts[0])
GOTMPDIR := strings.TrimSpace(parts[1])
diff --git a/src/cmd/go/internal/cache/cache.go b/src/cmd/go/internal/cache/cache.go
index 93d7c25..135ff92 100644
--- a/src/cmd/go/internal/cache/cache.go
+++ b/src/cmd/go/internal/cache/cache.go
@@ -54,7 +54,7 @@
return nil, err
}
if !info.IsDir() {
- return nil, &fs.PathError{Op: "open", Path: dir, Err: fmt.Errorf("not a directory")}
+ return nil, &fs.PathError{Op: "open", Path: dir, Err: errors.New("not a directory")}
}
for i := 0; i < 256; i++ {
name := filepath.Join(dir, fmt.Sprintf("%02x", i))
@@ -514,7 +514,7 @@
sum := h.Sum(nil)
if !bytes.Equal(sum, out[:]) {
f.Truncate(0)
- return fmt.Errorf("file content changed underfoot")
+ return errors.New("file content changed underfoot")
}

// Commit cache file entry.
diff --git a/src/cmd/go/internal/cache/default.go b/src/cmd/go/internal/cache/default.go
index 426dddf..7c9db9f 100644
--- a/src/cmd/go/internal/cache/default.go
+++ b/src/cmd/go/internal/cache/default.go
@@ -5,6 +5,7 @@
package cache

import (
+ "errors"
"fmt"
"os"
"path/filepath"
@@ -80,7 +81,7 @@
}
if defaultDir != "" {
defaultDir = "off"
- defaultDirErr = fmt.Errorf("GOCACHE is not an absolute path")
+ defaultDirErr = errors.New("GOCACHE is not an absolute path")
return
}

diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go
index a11a1a7..639b4d1 100644
--- a/src/cmd/go/internal/cfg/cfg.go
+++ b/src/cmd/go/internal/cfg/cfg.go
@@ -8,6 +8,7 @@

import (
"bytes"
+ "errors"
"fmt"
"go/build"
"internal/buildcfg"
@@ -216,7 +217,7 @@
func EnvFile() (string, error) {
if file := os.Getenv("GOENV"); file != "" {
if file == "off" {
- return "", fmt.Errorf("GOENV=off")
+ return "", errors.New("GOENV=off")
}
return file, nil
}
@@ -225,7 +226,7 @@
return "", err
}
if dir == "" {
- return "", fmt.Errorf("missing user-config dir")
+ return "", errors.New("missing user-config dir")
}
return filepath.Join(dir, "go/env"), nil
}
diff --git a/src/cmd/go/internal/fsys/fsys.go b/src/cmd/go/internal/fsys/fsys.go
index 9a1bbf8..233f5f5 100644
--- a/src/cmd/go/internal/fsys/fsys.go
+++ b/src/cmd/go/internal/fsys/fsys.go
@@ -118,7 +118,7 @@
to := overlayJSON.Replace[from]
// Canonicalize paths and check for a collision.
if from == "" {
- return fmt.Errorf("empty string key in overlay file Replace map")
+ return errors.New("empty string key in overlay file Replace map")
}
cfrom := canonicalize(from)
if to != "" {
diff --git a/src/cmd/go/internal/generate/generate.go b/src/cmd/go/internal/generate/generate.go
index 54ccfe7..50aa038 100644
--- a/src/cmd/go/internal/generate/generate.go
+++ b/src/cmd/go/internal/generate/generate.go
@@ -9,6 +9,7 @@
"bufio"
"bytes"
"context"
+ "errors"
"fmt"
"go/parser"
"go/token"
@@ -403,7 +404,7 @@
return words
}

-var stop = fmt.Errorf("error in generation")
+var stop = errors.New("error in generation")

// errorf logs an error message prefixed with the file and line number.
// It then exits the program (with exit status 1) because generation stops
diff --git a/src/cmd/go/internal/get/get.go b/src/cmd/go/internal/get/get.go
index 8cf8fe6..e221a03 100644
--- a/src/cmd/go/internal/get/get.go
+++ b/src/cmd/go/internal/get/get.go
@@ -7,6 +7,7 @@

import (
"context"
+ "errors"
"fmt"
"os"
"path/filepath"
@@ -503,11 +504,11 @@
// Package not found. Put in first directory of $GOPATH.
list := filepath.SplitList(cfg.BuildContext.GOPATH)
if len(list) == 0 {
- return fmt.Errorf("cannot download, $GOPATH not set. For more details see: 'go help gopath'")
+ return errors.New("cannot download, $GOPATH not set. For more details see: 'go help gopath'")
}
// Guard against people setting GOPATH=$GOROOT.
if filepath.Clean(list[0]) == filepath.Clean(cfg.GOROOT) {
- return fmt.Errorf("cannot download, $GOPATH must not be set to $GOROOT. For more details see: 'go help gopath'")
+ return errors.New("cannot download, $GOPATH must not be set to $GOROOT. For more details see: 'go help gopath'")
}
if _, err := os.Stat(filepath.Join(list[0], "src/cmd/go/alldocs.go")); err == nil {
return fmt.Errorf("cannot download, %s is a GOROOT, not a GOPATH. For more details see: 'go help gopath'", list[0])
diff --git a/src/cmd/go/internal/imports/scan.go b/src/cmd/go/internal/imports/scan.go
index ee11a87..e19e13a 100644
--- a/src/cmd/go/internal/imports/scan.go
+++ b/src/cmd/go/internal/imports/scan.go
@@ -5,6 +5,7 @@
package imports

import (
+ "errors"
"fmt"
"io/fs"
"path/filepath"
@@ -95,7 +96,7 @@
return keys(imports), keys(testImports), nil
}

-var ErrNoGo = fmt.Errorf("no Go source files")
+var ErrNoGo = errors.New("no Go source files")

func keys(m map[string]bool) []string {
var list []string
diff --git a/src/cmd/go/internal/load/flag.go b/src/cmd/go/internal/load/flag.go
index de079de..c970a91 100644
--- a/src/cmd/go/internal/load/flag.go
+++ b/src/cmd/go/internal/load/flag.go
@@ -7,7 +7,7 @@
import (
"cmd/go/internal/base"
"cmd/internal/quoted"
- "fmt"
+ "errors"
"strings"
)

@@ -54,10 +54,10 @@
if !strings.HasPrefix(v, "-") {
i := strings.Index(v, "=")
if i < 0 {
- return fmt.Errorf("missing =<value> in <pattern>=<value>")
+ return errors.New("missing =<value> in <pattern>=<value>")
}
if i == 0 {
- return fmt.Errorf("missing <pattern> in <pattern>=<value>")
+ return errors.New("missing <pattern> in <pattern>=<value>")
}
pattern := strings.TrimSpace(v[:i])
match = MatchPackage(pattern, cwd)
diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go
index 2592cf5..d3d737b 100644
--- a/src/cmd/go/internal/load/pkg.go
+++ b/src/cmd/go/internal/load/pkg.go
@@ -2041,7 +2041,7 @@
}
// Check pattern is valid for //go:embed.
if _, err := path.Match(glob, ""); err != nil || !validEmbedPattern(glob) {
- return nil, nil, fmt.Errorf("invalid pattern syntax")
+ return nil, nil, errors.New("invalid pattern syntax")
}

// Glob to find matches.
@@ -2143,7 +2143,7 @@
}

if len(list) == 0 {
- return nil, nil, fmt.Errorf("no matching files found")
+ return nil, nil, errors.New("no matching files found")
}
sort.Strings(list)
pmap[pattern] = list
diff --git a/src/cmd/go/internal/modfetch/cache.go b/src/cmd/go/internal/modfetch/cache.go
index b0dae1c..c4943ef 100644
--- a/src/cmd/go/internal/modfetch/cache.go
+++ b/src/cmd/go/internal/modfetch/cache.go
@@ -409,7 +409,7 @@
return sum, nil
}

-var errNotCached = fmt.Errorf("not in cache")
+var errNotCached = errors.New("not in cache")

// readDiskStat reads a cached stat result from disk,
// returning the name of the cache file and the result.
@@ -720,7 +720,7 @@
if cfg.GOMODCACHE == "" {
// modload.Init exits if GOPATH[0] is empty, and cfg.GOMODCACHE
// is set to GOPATH[0]/pkg/mod if GOMODCACHE is empty, so this should never happen.
- return fmt.Errorf("module cache not found: neither GOMODCACHE nor GOPATH is set")
+ return errors.New("module cache not found: neither GOMODCACHE nor GOPATH is set")
}
if !filepath.IsAbs(cfg.GOMODCACHE) {
return fmt.Errorf("GOMODCACHE entry is relative; must be absolute path: %q.\n", cfg.GOMODCACHE)
diff --git a/src/cmd/go/internal/modfetch/codehost/codehost.go b/src/cmd/go/internal/modfetch/codehost/codehost.go
index d8d4392..293851c 100644
--- a/src/cmd/go/internal/modfetch/codehost/codehost.go
+++ b/src/cmd/go/internal/modfetch/codehost/codehost.go
@@ -9,6 +9,7 @@
import (
"bytes"
"crypto/sha256"
+ "errors"
"fmt"
exec "internal/execabs"
"io"
@@ -134,7 +135,7 @@
// given repository type and name.
func WorkDir(typ, name string) (dir, lockfile string, err error) {
if cfg.GOMODCACHE == "" {
- return "", "", fmt.Errorf("neither GOPATH nor GOMODCACHE are set")
+ return "", "", errors.New("neither GOPATH nor GOMODCACHE are set")
}

// We name the work directory for the SHA256 hash of the type and name.
@@ -143,7 +144,7 @@
// that one checkout is never nested inside another. That nesting has
// led to security problems in the past.
if strings.Contains(typ, ":") {
- return "", "", fmt.Errorf("codehost.WorkDir: type cannot contain colon")
+ return "", "", errors.New("codehost.WorkDir: type cannot contain colon")
}
key := typ + ":" + name
dir = filepath.Join(cfg.GOMODCACHE, "cache/vcs", fmt.Sprintf("%x", sha256.Sum256([]byte(key))))
diff --git a/src/cmd/go/internal/modfetch/codehost/git.go b/src/cmd/go/internal/modfetch/codehost/git.go
index 34f453c..6edf205 100644
--- a/src/cmd/go/internal/modfetch/codehost/git.go
+++ b/src/cmd/go/internal/modfetch/codehost/git.go
@@ -102,10 +102,10 @@
// that's rcp-style host:path syntax and sometimes it's not (c:\work).
// The go command has always insisted on URL syntax for ssh.
if strings.Contains(remote, ":") {
- return nil, fmt.Errorf("git remote cannot use host:path syntax")
+ return nil, errors.New("git remote cannot use host:path syntax")
}
if !localOK {
- return nil, fmt.Errorf("git remote must not be local directory")
+ return nil, errors.New("git remote must not be local directory")
}
r.local = true
info, err := os.Stat(remote)
diff --git a/src/cmd/go/internal/modfetch/coderepo.go b/src/cmd/go/internal/modfetch/coderepo.go
index dfaf16d..6732ad4 100644
--- a/src/cmd/go/internal/modfetch/coderepo.go
+++ b/src/cmd/go/internal/modfetch/coderepo.go
@@ -633,7 +633,7 @@
}
if base == "" {
if r.pseudoMajor == "" && semver.Major(version) == "v1" {
- return fmt.Errorf("major version without preceding tag must be v0, not v1")
+ return errors.New("major version without preceding tag must be v0, not v1")
}
return nil
} else {
@@ -1006,7 +1006,7 @@
}
dl.Close()
if lr.N <= 0 {
- return fmt.Errorf("downloaded zip file too large")
+ return errors.New("downloaded zip file too large")
}
size := (maxSize + 1) - lr.N
if _, err := f.Seek(0, 0); err != nil {
@@ -1029,12 +1029,12 @@
if topPrefix == "" {
i := strings.Index(zf.Name, "/")
if i < 0 {
- return fmt.Errorf("missing top-level directory prefix")
+ return errors.New("missing top-level directory prefix")
}
topPrefix = zf.Name[:i+1]
}
if !strings.HasPrefix(zf.Name, topPrefix) {
- return fmt.Errorf("zip file contains more than one top-level directory")
+ return errors.New("zip file contains more than one top-level directory")
}
name := strings.TrimPrefix(zf.Name, topPrefix)
if !strings.HasPrefix(name, subdir) {
diff --git a/src/cmd/go/internal/modfetch/proxy.go b/src/cmd/go/internal/modfetch/proxy.go
index 31d453c..4b27da9 100644
--- a/src/cmd/go/internal/modfetch/proxy.go
+++ b/src/cmd/go/internal/modfetch/proxy.go
@@ -119,7 +119,7 @@
// There were no proxies, other than the implicit "noproxy" added when
// GONOPROXY is set. This can happen if GOPROXY is a non-empty string
// like "," or " ".
- proxyOnce.err = fmt.Errorf("GOPROXY list is not the empty string, but contains no entries")
+ proxyOnce.err = errors.New("GOPROXY list is not the empty string, but contains no entries")
}
})

@@ -384,7 +384,7 @@

func (p *proxyRepo) GoMod(version string) ([]byte, error) {
if version != module.CanonicalVersion(version) {
- return nil, p.versionError(version, fmt.Errorf("internal error: version passed to GoMod is not canonical"))
+ return nil, p.versionError(version, errors.New("internal error: version passed to GoMod is not canonical"))
}

encVer, err := module.EscapeVersion(version)
@@ -400,7 +400,7 @@

func (p *proxyRepo) Zip(dst io.Writer, version string) error {
if version != module.CanonicalVersion(version) {
- return p.versionError(version, fmt.Errorf("internal error: version passed to Zip is not canonical"))
+ return p.versionError(version, errors.New("internal error: version passed to Zip is not canonical"))
}

encVer, err := module.EscapeVersion(version)
@@ -418,7 +418,7 @@
return p.versionError(version, err)
}
if lr.N <= 0 {
- return p.versionError(version, fmt.Errorf("downloaded zip file too large"))
+ return p.versionError(version, errors.New("downloaded zip file too large"))
}
return nil
}
diff --git a/src/cmd/go/internal/modfetch/sumdb.go b/src/cmd/go/internal/modfetch/sumdb.go
index 492b03b..26cfb77 100644
--- a/src/cmd/go/internal/modfetch/sumdb.go
+++ b/src/cmd/go/internal/modfetch/sumdb.go
@@ -77,10 +77,10 @@
}
}
if len(key) == 0 {
- return "", nil, fmt.Errorf("missing GOSUMDB")
+ return "", nil, errors.New("missing GOSUMDB")
}
if len(key) > 2 {
- return "", nil, fmt.Errorf("invalid GOSUMDB: too many fields")
+ return "", nil, errors.New("invalid GOSUMDB: too many fields")
}
vkey, err := note.NewVerifier(key[0])
if err != nil {
@@ -217,7 +217,7 @@
func (*dbClient) WriteConfig(file string, old, new []byte) error {
if file == "key" {
// Should not happen.
- return fmt.Errorf("cannot write key")
+ return errors.New("cannot write key")
}
if cfg.SumdbDir == "" {
return fmt.Errorf("could not locate sumdb file: missing $GOPATH: %s",
diff --git a/src/cmd/go/internal/modget/get.go b/src/cmd/go/internal/modget/get.go
index 3d8463e..645f69c 100644
--- a/src/cmd/go/internal/modget/get.go
+++ b/src/cmd/go/internal/modget/get.go
@@ -693,7 +693,7 @@

if len(match.Pkgs) == 0 {
if q.raw == "" || q.raw == "." {
- return errSet(fmt.Errorf("no package to get in current directory"))
+ return errSet(errors.New("no package to get in current directory"))
}
if !q.isWildcard() {
modload.MustHaveModRoot()
diff --git a/src/cmd/go/internal/modload/init.go b/src/cmd/go/internal/modload/init.go
index f960edd..51f53d5 100644
--- a/src/cmd/go/internal/modload/init.go
+++ b/src/cmd/go/internal/modload/init.go
@@ -1556,7 +1556,7 @@
// a lot of work for marginal benefit. Instead, fail the command: if users
// want to run concurrent commands, they need to start with a complete,
// consistent module definition.
- return nil, fmt.Errorf("existing contents have changed since last read")
+ return nil, errors.New("existing contents have changed since last read")
}

return new, nil
diff --git a/src/cmd/go/internal/test/testflag.go b/src/cmd/go/internal/test/testflag.go
index c046cac..13775b9 100644
--- a/src/cmd/go/internal/test/testflag.go
+++ b/src/cmd/go/internal/test/testflag.go
@@ -190,9 +190,9 @@
*f = vetFlag{flags: defaultVetFlags}
return nil
case strings.Contains(value, "="):
- return fmt.Errorf("-vet argument cannot contain equal signs")
+ return errors.New("-vet argument cannot contain equal signs")
case strings.Contains(value, " "):
- return fmt.Errorf("-vet argument is comma-separated list, cannot contain spaces")
+ return errors.New("-vet argument is comma-separated list, cannot contain spaces")
}

*f = vetFlag{explicit: true}
@@ -200,7 +200,7 @@
for _, arg := range strings.Split(value, ",") {
switch arg {
case "":
- return fmt.Errorf("-vet argument contains empty list element")
+ return errors.New("-vet argument contains empty list element")
case "all":
single = arg
*f = vetFlag{explicit: true}
diff --git a/src/cmd/go/internal/vcs/vcs.go b/src/cmd/go/internal/vcs/vcs.go
index 2acabf7..b50dbcd 100644
--- a/src/cmd/go/internal/vcs/vcs.go
+++ b/src/cmd/go/internal/vcs/vcs.go
@@ -382,12 +382,12 @@
}
}
if !found {
- return "", fmt.Errorf("unable to parse output of bzr info")
+ return "", errors.New("unable to parse output of bzr info")
}

i := strings.Index(out, "\n")
if i < 0 {
- return "", fmt.Errorf("unable to parse output of bzr info")
+ return "", errors.New("unable to parse output of bzr info")
}
out = out[:i]
return strings.TrimSpace(out), nil
@@ -486,12 +486,12 @@
// while the Repository Root may be a much higher parent.
i := strings.Index(out, "\nURL: ")
if i < 0 {
- return "", fmt.Errorf("unable to parse output of svn info")
+ return "", errors.New("unable to parse output of svn info")
}
out = out[i+len("\nURL: "):]
i = strings.Index(out, "\n")
if i < 0 {
- return "", fmt.Errorf("unable to parse output of svn info")
+ return "", errors.New("unable to parse output of svn info")
}
out = out[:i]
return strings.TrimSpace(out), nil
@@ -870,7 +870,7 @@
for _, item := range strings.Split(s, ",") {
item = strings.TrimSpace(item)
if item == "" {
- return nil, fmt.Errorf("empty entry in GOVCS")
+ return nil, errors.New("empty entry in GOVCS")
}
i := strings.Index(item, ":")
if i < 0 {
@@ -1083,14 +1083,14 @@
// tests like ../../testdata/script/mod_get_extra.txt from using the network.
// That script has everything it needs in the replacement set, but it is still
// doing network calls.
- return nil, fmt.Errorf("no modules on example.net")
+ return nil, errors.New("no modules on example.net")
}
if importPath == "rsc.io" {
// This special case allows tests like ../../testdata/script/govcs.txt
// to avoid making any network calls. The module lookup for a path
// like rsc.io/nonexist.svn/foo needs to not make a network call for
// a lookup on rsc.io.
- return nil, fmt.Errorf("rsc.io is not a module")
+ return nil, errors.New("rsc.io is not a module")
}
// A common error is to use https://packagepath because that's what
// hg and git require. Diagnose this helpfully.
diff --git a/src/cmd/go/internal/web/http.go b/src/cmd/go/internal/web/http.go
index a92326d..0a0f83b 100644
--- a/src/cmd/go/internal/web/http.go
+++ b/src/cmd/go/internal/web/http.go
@@ -82,7 +82,7 @@
}

if url.Host == "localhost.localdev" {
- return nil, fmt.Errorf("no such host localhost.localdev")
+ return nil, errors.New("no such host localhost.localdev")
}
if os.Getenv("TESTGONETWORK") == "panic" {
host := url.Host
diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
index 6d6837a..2b9140a 100644
--- a/src/cmd/go/internal/work/exec.go
+++ b/src/cmd/go/internal/work/exec.go
@@ -1134,7 +1134,7 @@
vcfg := a.Deps[0].vetCfg
if vcfg == nil {
// Vet config should only be missing if the build failed.
- return fmt.Errorf("vet config not found")
+ return errors.New("vet config not found")
}

vcfg.VetxOnly = a.VetxOnly
diff --git a/src/cmd/go/internal/work/gc.go b/src/cmd/go/internal/work/gc.go
index fdde3b2..5838ce8 100644
--- a/src/cmd/go/internal/work/gc.go
+++ b/src/cmd/go/internal/work/gc.go
@@ -7,6 +7,7 @@
import (
"bufio"
"bytes"
+ "errors"
"fmt"
"io"
"log"
@@ -541,7 +542,7 @@
if err == nil && n < size {
err = io.ErrUnexpectedEOF
} else if err == nil && n > size {
- err = fmt.Errorf("file larger than size reported by stat")
+ err = errors.New("file larger than size reported by stat")
}
if err != nil {
return fmt.Errorf("copying %s to %s: %v", ofile, afile, err)
diff --git a/src/cmd/go/internal/work/gccgo.go b/src/cmd/go/internal/work/gccgo.go
index 1499536..22605f9 100644
--- a/src/cmd/go/internal/work/gccgo.go
+++ b/src/cmd/go/internal/work/gccgo.go
@@ -5,6 +5,7 @@
package work

import (
+ "errors"
"fmt"
exec "internal/execabs"
"os"
@@ -191,7 +192,7 @@
return err
}
case "packageshlib":
- return fmt.Errorf("gccgo -importcfg does not support shared libraries")
+ return errors.New("gccgo -importcfg does not support shared libraries")
}
}
return nil
diff --git a/src/cmd/gofmt/gofmt.go b/src/cmd/gofmt/gofmt.go
index 5fa883f..97a7fd5 100644
--- a/src/cmd/gofmt/gofmt.go
+++ b/src/cmd/gofmt/gofmt.go
@@ -7,6 +7,7 @@
import (
"bytes"
"context"
+ "errors"
"flag"
"fmt"
"go/ast"
@@ -404,7 +405,7 @@
args := flag.Args()
if len(args) == 0 {
if *write {
- s.AddReport(fmt.Errorf("error: cannot use -w with standard input"))
+ s.AddReport(errors.New("error: cannot use -w with standard input"))
return
}
s.Add(0, func(r *reporter) error {
diff --git a/src/cmd/internal/archive/archive.go b/src/cmd/internal/archive/archive.go
index da1f293..79707eb 100644
--- a/src/cmd/internal/archive/archive.go
+++ b/src/cmd/internal/archive/archive.go
@@ -211,7 +211,7 @@
// skip skips n bytes in the input.
func (r *objReader) skip(n int64) {
if n < 0 {
- r.error(fmt.Errorf("debug/goobj: internal error: misuse of skip"))
+ r.error(errors.New("debug/goobj: internal error: misuse of skip"))
}
if n < int64(len(r.tmp)) {
// Since the data is so small, a just reading from the buffered
diff --git a/src/cmd/internal/buildid/buildid.go b/src/cmd/internal/buildid/buildid.go
index 1e8855d..2b1a00b 100644
--- a/src/cmd/internal/buildid/buildid.go
+++ b/src/cmd/internal/buildid/buildid.go
@@ -7,7 +7,7 @@
import (
"bytes"
"debug/elf"
- "fmt"
+ "errors"
"internal/xcoff"
"io"
"io/fs"
@@ -17,7 +17,7 @@
)

var (
- errBuildIDMalformed = fmt.Errorf("malformed object file")
+ errBuildIDMalformed = errors.New("malformed object file")

bangArch = []byte("!<arch>")
pkgdef = []byte("__.PKGDEF")
diff --git a/src/cmd/internal/buildid/note.go b/src/cmd/internal/buildid/note.go
index f5b6fc5..cdbded7 100644
--- a/src/cmd/internal/buildid/note.go
+++ b/src/cmd/internal/buildid/note.go
@@ -9,6 +9,7 @@
"debug/elf"
"debug/macho"
"encoding/binary"
+ "errors"
"fmt"
"io"
"io/fs"
@@ -188,7 +189,7 @@
sect := mf.Section("__text")
if sect == nil {
// Every binary has a __text section. Something is wrong.
- return "", &fs.PathError{Path: name, Op: "parse", Err: fmt.Errorf("cannot find __text section")}
+ return "", &fs.PathError{Path: name, Op: "parse", Err: errors.New("cannot find __text section")}
}

// It should be in the first few bytes, but read a lot just in case,
diff --git a/src/cmd/internal/buildid/rewrite.go b/src/cmd/internal/buildid/rewrite.go
index becc078..8fef6cb 100644
--- a/src/cmd/internal/buildid/rewrite.go
+++ b/src/cmd/internal/buildid/rewrite.go
@@ -9,7 +9,7 @@
"cmd/internal/codesign"
"crypto/sha256"
"debug/macho"
- "fmt"
+ "errors"
"io"
)

@@ -23,10 +23,10 @@
bufSize = 31 * 1024 // bufSize+little will likely fit in 32 kB
}
if len(id) == 0 {
- return nil, [32]byte{}, fmt.Errorf("buildid.FindAndHash: no id specified")
+ return nil, [32]byte{}, errors.New("buildid.FindAndHash: no id specified")
}
if len(id) > bufSize {
- return nil, [32]byte{}, fmt.Errorf("buildid.FindAndHash: buffer too small")
+ return nil, [32]byte{}, errors.New("buildid.FindAndHash: buffer too small")
}
zeros := make([]byte, len(id))
idBytes := []byte(id)
diff --git a/src/cmd/internal/obj/riscv/obj.go b/src/cmd/internal/obj/riscv/obj.go
index 47dbfc0..0078a6b 100644
--- a/src/cmd/internal/obj/riscv/obj.go
+++ b/src/cmd/internal/obj/riscv/obj.go
@@ -24,6 +24,7 @@
"cmd/internal/obj"
"cmd/internal/objabi"
"cmd/internal/sys"
+ "errors"
"fmt"
"log"
)
@@ -1626,7 +1627,7 @@
if enc.length > 0 {
return enc.encode(ins), nil
}
- return 0, fmt.Errorf("fixme")
+ return 0, errors.New("fixme")
}

func (ins *instruction) length() int {
diff --git a/src/cmd/internal/objfile/disasm.go b/src/cmd/internal/objfile/disasm.go
index b5f1cd1..60d9eeb 100644
--- a/src/cmd/internal/objfile/disasm.go
+++ b/src/cmd/internal/objfile/disasm.go
@@ -11,6 +11,7 @@
"container/list"
"debug/gosym"
"encoding/binary"
+ "errors"
"fmt"
"io"
"io/ioutil"
@@ -60,7 +61,7 @@
disasm := disasms[goarch]
byteOrder := byteOrders[goarch]
if disasm == nil || byteOrder == nil {
- return nil, fmt.Errorf("unsupported architecture")
+ return nil, errors.New("unsupported architecture")
}

// Filter out section symbols, overwriting syms in place.
diff --git a/src/cmd/internal/objfile/elf.go b/src/cmd/internal/objfile/elf.go
index a48a9df..b96f529 100644
--- a/src/cmd/internal/objfile/elf.go
+++ b/src/cmd/internal/objfile/elf.go
@@ -10,7 +10,7 @@
"debug/dwarf"
"debug/elf"
"encoding/binary"
- "fmt"
+ "errors"
"io"
)

@@ -84,7 +84,7 @@
func (f *elfFile) text() (textStart uint64, text []byte, err error) {
sect := f.elf.Section(".text")
if sect == nil {
- return 0, nil, fmt.Errorf("text section not found")
+ return 0, nil, errors.New("text section not found")
}
textStart = sect.Addr
text, err = sect.Data()
@@ -118,7 +118,7 @@
return p.Vaddr, nil
}
}
- return 0, fmt.Errorf("unknown load address")
+ return 0, errors.New("unknown load address")
}

func (f *elfFile) dwarf() (*dwarf.Data, error) {
diff --git a/src/cmd/internal/objfile/goobj.go b/src/cmd/internal/objfile/goobj.go
index 24d2d0b..5d6fe7f 100644
--- a/src/cmd/internal/objfile/goobj.go
+++ b/src/cmd/internal/objfile/goobj.go
@@ -223,7 +223,7 @@
func (f *goobjFile) pcln() (textStart uint64, symtab, pclntab []byte, err error) {
// Should never be called. We implement Liner below, callers
// should use that instead.
- return 0, nil, nil, fmt.Errorf("pcln not available in go object file")
+ return 0, nil, nil, errors.New("pcln not available in go object file")
}

// Find returns the file name, line, and function data for the given pc.
@@ -333,7 +333,7 @@
}

func (f *goobjFile) loadAddress() (uint64, error) {
- return 0, fmt.Errorf("unknown load address")
+ return 0, errors.New("unknown load address")
}

func (f *goobjFile) dwarf() (*dwarf.Data, error) {
diff --git a/src/cmd/internal/objfile/macho.go b/src/cmd/internal/objfile/macho.go
index 1d6963f..6a04ad7 100644
--- a/src/cmd/internal/objfile/macho.go
+++ b/src/cmd/internal/objfile/macho.go
@@ -9,7 +9,7 @@
import (
"debug/dwarf"
"debug/macho"
- "fmt"
+ "errors"
"io"
"sort"
)
@@ -98,7 +98,7 @@
func (f *machoFile) text() (textStart uint64, text []byte, err error) {
sect := f.macho.Section("__text")
if sect == nil {
- return 0, nil, fmt.Errorf("text section not found")
+ return 0, nil, errors.New("text section not found")
}
textStart = sect.Addr
text, err = sect.Data()
@@ -128,7 +128,7 @@
func (x uint64s) Less(i, j int) bool { return x[i] < x[j] }

func (f *machoFile) loadAddress() (uint64, error) {
- return 0, fmt.Errorf("unknown load address")
+ return 0, errors.New("unknown load address")
}

func (f *machoFile) dwarf() (*dwarf.Data, error) {
diff --git a/src/cmd/internal/objfile/pe.go b/src/cmd/internal/objfile/pe.go
index 9088866..49d7fb9 100644
--- a/src/cmd/internal/objfile/pe.go
+++ b/src/cmd/internal/objfile/pe.go
@@ -9,6 +9,7 @@
import (
"debug/dwarf"
"debug/pe"
+ "errors"
"fmt"
"io"
"sort"
@@ -56,7 +57,7 @@
sym.Code = '?'
default:
if s.SectionNumber < 0 || len(f.pe.Sections) < int(s.SectionNumber) {
- return nil, fmt.Errorf("invalid section number in symbol table")
+ return nil, errors.New("invalid section number in symbol table")
}
sect := f.pe.Sections[s.SectionNumber-1]
const (
@@ -103,7 +104,7 @@
case *pe.OptionalHeader64:
imageBase = oh.ImageBase
default:
- return 0, nil, nil, fmt.Errorf("pe file format not recognized")
+ return 0, nil, nil, errors.New("pe file format not recognized")
}
if sect := f.pe.Section(".text"); sect != nil {
textStart = imageBase + uint64(sect.VirtualAddress)
@@ -134,11 +135,11 @@
case *pe.OptionalHeader64:
imageBase = oh.ImageBase
default:
- return 0, nil, fmt.Errorf("pe file format not recognized")
+ return 0, nil, errors.New("pe file format not recognized")
}
sect := f.pe.Section(".text")
if sect == nil {
- return 0, nil, fmt.Errorf("text section not found")
+ return 0, nil, errors.New("text section not found")
}
textStart = imageBase + uint64(sect.VirtualAddress)
text, err = sect.Data()
@@ -197,7 +198,7 @@
}

func (f *peFile) loadAddress() (uint64, error) {
- return 0, fmt.Errorf("unknown load address")
+ return 0, errors.New("unknown load address")
}

func (f *peFile) dwarf() (*dwarf.Data, error) {
diff --git a/src/cmd/internal/objfile/plan9obj.go b/src/cmd/internal/objfile/plan9obj.go
index da0b345..a1cabd0 100644
--- a/src/cmd/internal/objfile/plan9obj.go
+++ b/src/cmd/internal/objfile/plan9obj.go
@@ -93,7 +93,7 @@
func (f *plan9File) text() (textStart uint64, text []byte, err error) {
sect := f.plan9.Section("text")
if sect == nil {
- return 0, nil, fmt.Errorf("text section not found")
+ return 0, nil, errors.New("text section not found")
}
textStart = f.plan9.LoadAddress + f.plan9.HdrSize
text, err = sect.Data()
@@ -148,7 +148,7 @@
}

func (f *plan9File) loadAddress() (uint64, error) {
- return 0, fmt.Errorf("unknown load address")
+ return 0, errors.New("unknown load address")
}

func (f *plan9File) dwarf() (*dwarf.Data, error) {
diff --git a/src/cmd/internal/objfile/xcoff.go b/src/cmd/internal/objfile/xcoff.go
index d6df4db..1f2531b 100644
--- a/src/cmd/internal/objfile/xcoff.go
+++ b/src/cmd/internal/objfile/xcoff.go
@@ -8,6 +8,7 @@

import (
"debug/dwarf"
+ "errors"
"fmt"
"internal/xcoff"
"io"
@@ -45,7 +46,7 @@
sym.Code = '?'
default:
if s.SectionNumber < 0 || len(f.xcoff.Sections) < int(s.SectionNumber) {
- return nil, fmt.Errorf("invalid section number in symbol table")
+ return nil, errors.New("invalid section number in symbol table")
}
sect := f.xcoff.Sections[s.SectionNumber-1]

@@ -101,7 +102,7 @@
func (f *xcoffFile) text() (textStart uint64, text []byte, err error) {
sect := f.xcoff.Section(".text")
if sect == nil {
- return 0, nil, fmt.Errorf("text section not found")
+ return 0, nil, errors.New("text section not found")
}
textStart = sect.VirtualAddress
text, err = sect.Data()
@@ -155,7 +156,7 @@
}

func (f *xcoffFile) loadAddress() (uint64, error) {
- return 0, fmt.Errorf("unknown load address")
+ return 0, errors.New("unknown load address")
}

func (f *xcoffFile) dwarf() (*dwarf.Data, error) {
diff --git a/src/cmd/internal/osinfo/os_js.go b/src/cmd/internal/osinfo/os_js.go
index 882580d..8111f03 100644
--- a/src/cmd/internal/osinfo/os_js.go
+++ b/src/cmd/internal/osinfo/os_js.go
@@ -17,5 +17,5 @@
// WASI (see https://go.dev/issue/31105). We could attempt multiple
// combinations, but for now we leave this unimplemented for
// simplicity.
- return "", fmt.Errorf("unimplemented")
+ return "", errors.New("unimplemented")
}
diff --git a/src/cmd/link/internal/ld/macho.go b/src/cmd/link/internal/ld/macho.go
index 8633222..3c05f92 100644
--- a/src/cmd/link/internal/ld/macho.go
+++ b/src/cmd/link/internal/ld/macho.go
@@ -13,6 +13,7 @@
"cmd/link/internal/sym"
"debug/macho"
"encoding/binary"
+ "errors"
"fmt"
"internal/buildcfg"
"io"
@@ -1528,7 +1529,7 @@
if sigOff+sigSz != fi.Size() {
// We don't expect anything after the signature (this will invalidate
// the signature anyway.)
- return fmt.Errorf("unexpected content after code signature")
+ return errors.New("unexpected content after code signature")
}

sz := codesign.Size(sigOff, "a.out")
diff --git a/src/cmd/link/internal/ld/macho_combine_dwarf.go b/src/cmd/link/internal/ld/macho_combine_dwarf.go
index 2ab7da9..65513d7 100644
--- a/src/cmd/link/internal/ld/macho_combine_dwarf.go
+++ b/src/cmd/link/internal/ld/macho_combine_dwarf.go
@@ -9,6 +9,7 @@
"compress/zlib"
"debug/macho"
"encoding/binary"
+ "errors"
"fmt"
"io"
"os"
@@ -109,7 +110,7 @@
// linkedit section, but all the others can be copied directly.
linkseg := exem.Segment("__LINKEDIT")
if linkseg == nil {
- return fmt.Errorf("missing __LINKEDIT segment")
+ return errors.New("missing __LINKEDIT segment")
}

if _, err := exef.Seek(0, 0); err != nil {
@@ -121,7 +122,7 @@

realdwarf := dwarfm.Segment("__DWARF")
if realdwarf == nil {
- return fmt.Errorf("missing __DWARF segment")
+ return errors.New("missing __DWARF segment")
}

// Try to compress the DWARF sections. This includes some Apple
@@ -173,7 +174,7 @@
// Now we need to update the headers.
textsect := exem.Section("__text")
if textsect == nil {
- return fmt.Errorf("missing __text section")
+ return errors.New("missing __text section")
}

cmdOffset := unsafe.Sizeof(exem.FileHeader)
diff --git a/src/cmd/link/internal/loadelf/ldelf.go b/src/cmd/link/internal/loadelf/ldelf.go
index d05d8e3..887de7e 100644
--- a/src/cmd/link/internal/loadelf/ldelf.go
+++ b/src/cmd/link/internal/loadelf/ldelf.go
@@ -14,6 +14,7 @@
"cmd/link/internal/sym"
"debug/elf"
"encoding/binary"
+ "errors"
"fmt"
"io"
"log"
@@ -200,7 +201,7 @@

nulIndex := bytes.IndexByte(sectiondata, 0)
if nulIndex < 0 {
- return false, 0, fmt.Errorf("corrupt .ARM.attributes (section name not NUL-terminated)\n")
+ return false, 0, errors.New("corrupt .ARM.attributes (section name not NUL-terminated)\n")
}
name := string(sectiondata[:nulIndex])
sectiondata = sectiondata[nulIndex+1:]
@@ -226,7 +227,7 @@
}
}
if attrList.err != nil {
- return false, 0, fmt.Errorf("could not parse .ARM.attributes\n")
+ return false, 0, errors.New("could not parse .ARM.attributes\n")
}
}
}
@@ -805,7 +806,7 @@
}

if sect.off+sect.size > uint64(elfobj.length) {
- err = fmt.Errorf("elf section past end of file")
+ err = errors.New("elf section past end of file")
return err
}

@@ -820,12 +821,12 @@

func readelfsym(newSym, lookup func(string, int) loader.Sym, l *loader.Loader, arch *sys.Arch, elfobj *ElfObj, i int, elfsym *ElfSym, needSym int, localSymVersion int) (err error) {
if i >= elfobj.nsymtab || i < 0 {
- err = fmt.Errorf("invalid elf symbol index")
+ err = errors.New("invalid elf symbol index")
return err
}

if i == 0 {
- return fmt.Errorf("readym: read null symbol!")
+ return errors.New("readym: read null symbol!")
}

if elfobj.is64 != 0 {
diff --git a/src/cmd/pprof/pprof.go b/src/cmd/pprof/pprof.go
index c073c96..421cfe4 100644
--- a/src/cmd/pprof/pprof.go
+++ b/src/cmd/pprof/pprof.go
@@ -12,6 +12,7 @@
import (
"crypto/tls"
"debug/dwarf"
+ "errors"
"fmt"
"io"
"net/http"
@@ -173,7 +174,7 @@

func (t *objTool) Disasm(file string, start, end uint64, intelSyntax bool) ([]driver.Inst, error) {
if intelSyntax {
- return nil, fmt.Errorf("printing assembly in Intel syntax is not supported")
+ return nil, errors.New("printing assembly in Intel syntax is not supported")
}
d, err := t.cachedDisasm(file)
if err != nil {
diff --git a/src/cmd/trace/annotations.go b/src/cmd/trace/annotations.go
index 1c0dad5..83b9c02 100644
--- a/src/cmd/trace/annotations.go
+++ b/src/cmd/trace/annotations.go
@@ -6,6 +6,7 @@

import (
"bytes"
+ "errors"
"fmt"
"html/template"
"internal/trace"
@@ -281,7 +282,7 @@

events := res.Events
if len(events) == 0 {
- return annotationAnalysisResult{}, fmt.Errorf("empty trace")
+ return annotationAnalysisResult{}, errors.New("empty trace")
}

tasks := allTasks{}
diff --git a/src/cmd/vet/testdata/unused/unused.go b/src/cmd/vet/testdata/unused/unused.go
index 1e83e90..4f555d6 100644
--- a/src/cmd/vet/testdata/unused/unused.go
+++ b/src/cmd/vet/testdata/unused/unused.go
@@ -6,8 +6,8 @@

package unused

-import "fmt"
+import "errors"

func _() {
- fmt.Errorf("") // ERROR "result of fmt.Errorf call not used"
+ errors.New("") // ERROR "result of errors.New call not used"
}
diff --git a/src/cmd/vet/vet_test.go b/src/cmd/vet/vet_test.go
index 714ee32..63d6c4b 100644
--- a/src/cmd/vet/vet_test.go
+++ b/src/cmd/vet/vet_test.go
@@ -257,7 +257,7 @@
}

if len(out) > 0 {
- errs = append(errs, fmt.Errorf("Unmatched Errors:"))
+ errs = append(errs, errors.New("Unmatched Errors:"))
for _, errLine := range out {
errs = append(errs, fmt.Errorf("%s", errLine))
}
diff --git a/src/compress/flate/deflate_test.go b/src/compress/flate/deflate_test.go
index ff56712..3e70d39 100644
--- a/src/compress/flate/deflate_test.go
+++ b/src/compress/flate/deflate_test.go
@@ -889,7 +889,7 @@
}

if !bytes.Equal(dst, src) {
- report("", fmt.Errorf("bytes differ after round-tripping"))
+ report("", errors.New("bytes differ after round-tripping"))
continue
}
}
diff --git a/src/crypto/tls/auth.go b/src/crypto/tls/auth.go
index a9df0da..a8a8303 100644
--- a/src/crypto/tls/auth.go
+++ b/src/crypto/tls/auth.go
@@ -139,7 +139,7 @@
// but it requires holding on to a handshake transcript to do a
// full signature, and not even OpenSSL bothers with the
// complexity, so we can't even test it properly.
- return 0, 0, fmt.Errorf("tls: Ed25519 public keys are not supported before TLS 1.2")
+ return 0, 0, errors.New("tls: Ed25519 public keys are not supported before TLS 1.2")
default:
return 0, 0, fmt.Errorf("tls: unsupported public key: %T", pub)
}
@@ -256,7 +256,7 @@
return fmt.Errorf("tls: unsupported certificate: private key is %T, expected *%T",
cert.PrivateKey, cert.PrivateKey)
case *ed25519.PrivateKey:
- return fmt.Errorf("tls: unsupported certificate: private key is *ed25519.PrivateKey, expected ed25519.PrivateKey")
+ return errors.New("tls: unsupported certificate: private key is *ed25519.PrivateKey, expected ed25519.PrivateKey")
}

signer, ok := cert.PrivateKey.(crypto.Signer)
@@ -275,14 +275,14 @@
return fmt.Errorf("tls: unsupported certificate curve (%s)", pub.Curve.Params().Name)
}
case *rsa.PublicKey:
- return fmt.Errorf("tls: certificate RSA key size too small for supported signature algorithms")
+ return errors.New("tls: certificate RSA key size too small for supported signature algorithms")
case ed25519.PublicKey:
default:
return fmt.Errorf("tls: unsupported certificate key (%T)", pub)
}

if cert.SupportedSignatureAlgorithms != nil {
- return fmt.Errorf("tls: peer doesn't support the certificate custom signature algorithms")
+ return errors.New("tls: peer doesn't support the certificate custom signature algorithms")
}

return fmt.Errorf("tls: internal error: unsupported key (%T)", cert.PrivateKey)
diff --git a/src/crypto/tls/handshake_client_test.go b/src/crypto/tls/handshake_client_test.go
index 0950bb0..21177f9 100644
--- a/src/crypto/tls/handshake_client_test.go
+++ b/src/crypto/tls/handshake_client_test.go
@@ -1564,7 +1564,7 @@
return fmt.Errorf("server: got len(PeerCertificates) = %d, wanted 1", l)
}
if len(c.VerifiedChains) == 0 {
- return fmt.Errorf("server: got len(VerifiedChains) = 0, wanted non-zero")
+ return errors.New("server: got len(VerifiedChains) = 0, wanted non-zero")
}
return checkFields(c, called, "server")
}
@@ -1576,7 +1576,7 @@
return fmt.Errorf("client: got len(PeerCertificates) = %d, wanted 1", l)
}
if len(c.VerifiedChains) == 0 {
- return fmt.Errorf("client: got len(VerifiedChains) = 0, wanted non-zero")
+ return errors.New("client: got len(VerifiedChains) = 0, wanted non-zero")
}
if c.DidResume {
return nil
@@ -1584,10 +1584,10 @@
// See http://golang.org/issue/39075.
}
if len(c.OCSPResponse) == 0 {
- return fmt.Errorf("client: got len(OCSPResponse) = 0, wanted non-zero")
+ return errors.New("client: got len(OCSPResponse) = 0, wanted non-zero")
}
if len(c.SignedCertificateTimestamps) == 0 {
- return fmt.Errorf("client: got len(SignedCertificateTimestamps) = 0, wanted non-zero")
+ return errors.New("client: got len(SignedCertificateTimestamps) = 0, wanted non-zero")
}
return checkFields(c, called, "client")
}
@@ -1625,10 +1625,10 @@
// See http://golang.org/issue/39075.
}
if len(c.OCSPResponse) == 0 {
- return fmt.Errorf("client: got len(OCSPResponse) = 0, wanted non-zero")
+ return errors.New("client: got len(OCSPResponse) = 0, wanted non-zero")
}
if len(c.SignedCertificateTimestamps) == 0 {
- return fmt.Errorf("client: got len(SignedCertificateTimestamps) = 0, wanted non-zero")
+ return errors.New("client: got len(SignedCertificateTimestamps) = 0, wanted non-zero")
}
return checkFields(c, called, "client")
}
@@ -1667,7 +1667,7 @@
return fmt.Errorf("client: got len(PeerCertificates) = %d, wanted 1", l)
}
if len(c.VerifiedChains) == 0 {
- return fmt.Errorf("client: got len(VerifiedChains) = 0, wanted non-zero")
+ return errors.New("client: got len(VerifiedChains) = 0, wanted non-zero")
}
if c.DidResume {
return nil
@@ -1675,10 +1675,10 @@
// See http://golang.org/issue/39075.
}
if len(c.OCSPResponse) == 0 {
- return fmt.Errorf("client: got len(OCSPResponse) = 0, wanted non-zero")
+ return errors.New("client: got len(OCSPResponse) = 0, wanted non-zero")
}
if len(c.SignedCertificateTimestamps) == 0 {
- return fmt.Errorf("client: got len(SignedCertificateTimestamps) = 0, wanted non-zero")
+ return errors.New("client: got len(SignedCertificateTimestamps) = 0, wanted non-zero")
}
return checkFields(c, called, "client")
}
@@ -1772,10 +1772,10 @@
return fmt.Errorf("got len(PeerCertificates) = %d, wanted 1", l)
}
if len(c.VerifiedChains) == 0 {
- return fmt.Errorf("got len(VerifiedChains) = 0, wanted non-zero")
+ return errors.New("got len(VerifiedChains) = 0, wanted non-zero")
}
if isClient && len(c.OCSPResponse) == 0 {
- return fmt.Errorf("got len(OCSPResponse) = 0, wanted non-zero")
+ return errors.New("got len(OCSPResponse) = 0, wanted non-zero")
}
*called = true
return nil
diff --git a/src/crypto/tls/handshake_server_test.go b/src/crypto/tls/handshake_server_test.go
index 6d2c405..2e74621 100644
--- a/src/crypto/tls/handshake_server_test.go
+++ b/src/crypto/tls/handshake_server_test.go
@@ -1528,7 +1528,7 @@
"",
func(config *Config) error {
if config.SessionTicketKey == [32]byte{} {
- return fmt.Errorf("expected SessionTicketKey to be set")
+ return errors.New("expected SessionTicketKey to be set")
}
return nil
},
@@ -1550,7 +1550,7 @@
"",
func(config *Config) error {
if config.SessionTicketKey == [32]byte{} {
- return fmt.Errorf("expected SessionTicketKey to be set")
+ return errors.New("expected SessionTicketKey to be set")
}
return nil
},
diff --git a/src/crypto/tls/prf.go b/src/crypto/tls/prf.go
index 13bfa00..8f1591b 100644
--- a/src/crypto/tls/prf.go
+++ b/src/crypto/tls/prf.go
@@ -270,7 +270,7 @@

if context != nil {
if len(context) >= 1<<16 {
- return nil, fmt.Errorf("crypto/tls: ExportKeyingMaterial context too long")
+ return nil, errors.New("crypto/tls: ExportKeyingMaterial context too long")
}
seed = append(seed, byte(len(context)>>8), byte(len(context)))
seed = append(seed, context...)
diff --git a/src/crypto/x509/parser.go b/src/crypto/x509/parser.go
index 333991b..39b8b6a 100644
--- a/src/crypto/x509/parser.go
+++ b/src/crypto/x509/parser.go
@@ -534,7 +534,7 @@
var tag cryptobyte_asn1.Tag
if !subtrees.ReadASN1(&seq, cryptobyte_asn1.SEQUENCE) ||
!seq.ReadAnyASN1(&value, &tag) {
- return nil, nil, nil, nil, fmt.Errorf("x509: invalid NameConstraints extension")
+ return nil, nil, nil, nil, errors.New("x509: invalid NameConstraints extension")
}

var (
diff --git a/src/crypto/x509/verify_test.go b/src/crypto/x509/verify_test.go
index 100a8ff..4380561 100644
--- a/src/crypto/x509/verify_test.go
+++ b/src/crypto/x509/verify_test.go
@@ -1525,7 +1525,7 @@
}
uae := &UnknownAuthorityError{
Cert: c,
- hintErr: fmt.Errorf("empty"),
+ hintErr: errors.New("empty"),
hintCert: c,
}
actual := uae.Error()
diff --git a/src/database/sql/convert_test.go b/src/database/sql/convert_test.go
index 6d09fa1..f102ccb 100644
--- a/src/database/sql/convert_test.go
+++ b/src/database/sql/convert_test.go
@@ -6,6 +6,7 @@

import (
"database/sql/driver"
+ "errors"
"fmt"
"reflect"
"runtime"
@@ -522,7 +523,7 @@
// This isn't strictly correct, as the extra bytes could be all zero,
// ignore this for this test.
if len(coefficient) > 16 {
- return fmt.Errorf("coefficient too large")
+ return errors.New("coefficient too large")
}
copy(d.coefficient[:], coefficient)

@@ -555,7 +556,7 @@
// This isn't strictly correct, as the extra bytes could be all zero,
// ignore this for this test.
if len(coefficient) > 16 {
- return fmt.Errorf("coefficient too large")
+ return errors.New("coefficient too large")
}
copy(d.coefficient[:], coefficient)

diff --git a/src/database/sql/driver/types.go b/src/database/sql/driver/types.go
index 506ce6c..ffebeae 100644
--- a/src/database/sql/driver/types.go
+++ b/src/database/sql/driver/types.go
@@ -5,6 +5,7 @@
package driver

import (
+ "errors"
"fmt"
"reflect"
"strconv"
@@ -167,7 +168,7 @@

func (n NotNull) ConvertValue(v any) (Value, error) {
if v == nil {
- return nil, fmt.Errorf("nil value not allowed")
+ return nil, errors.New("nil value not allowed")
}
return n.Converter.ConvertValue(v)
}
@@ -270,7 +271,7 @@
case reflect.Uint64:
u64 := rv.Uint()
if u64 >= 1<<63 {
- return nil, fmt.Errorf("uint64 values with high bit set are not supported")
+ return nil, errors.New("uint64 values with high bit set are not supported")
}
return int64(u64), nil
case reflect.Float32, reflect.Float64:
diff --git a/src/debug/buildinfo/buildinfo.go b/src/debug/buildinfo/buildinfo.go
index 8de03ff..a81d0dc 100644
--- a/src/debug/buildinfo/buildinfo.go
+++ b/src/debug/buildinfo/buildinfo.go
@@ -389,7 +389,7 @@
return data, nil
}
}
- return nil, fmt.Errorf("address not mapped")
+ return nil, errors.New("address not mapped")
}

func (x *xcoffExe) DataStart() uint64 {
diff --git a/src/debug/pe/file.go b/src/debug/pe/file.go
index aa0955a..d662b72 100644
--- a/src/debug/pe/file.go
+++ b/src/debug/pe/file.go
@@ -10,6 +10,7 @@
"compress/zlib"
"debug/dwarf"
"encoding/binary"
+ "errors"
"fmt"
"io"
"os"
@@ -468,7 +469,7 @@

// If optional header size is greater than 0 but less than its magic size, return error.
if sz < uint16(ohMagicSz) {
- return nil, fmt.Errorf("optional header size is less than optional header magic size")
+ return nil, errors.New("optional header size is less than optional header magic size")
}

// read reads from io.ReadSeeke, r, into data.
diff --git a/src/debug/pe/symbol.go b/src/debug/pe/symbol.go
index 0dfd5d9..0bbe31e 100644
--- a/src/debug/pe/symbol.go
+++ b/src/debug/pe/symbol.go
@@ -6,6 +6,7 @@

import (
"encoding/binary"
+ "errors"
"fmt"
"io"
"unsafe"
@@ -140,15 +141,15 @@
func (f *File) COFFSymbolReadSectionDefAux(idx int) (*COFFSymbolAuxFormat5, error) {
var rv *COFFSymbolAuxFormat5
if idx < 0 || idx > len(f.COFFSymbols) {
- return rv, fmt.Errorf("invalid symbol index")
+ return rv, errors.New("invalid symbol index")
}
pesym := &f.COFFSymbols[idx]
const IMAGE_SYM_CLASS_STATIC = 3
if pesym.StorageClass != uint8(IMAGE_SYM_CLASS_STATIC) {
- return rv, fmt.Errorf("incorrect symbol storage class")
+ return rv, errors.New("incorrect symbol storage class")
}
if pesym.NumberOfAuxSymbols == 0 || idx+1 >= len(f.COFFSymbols) {
- return rv, fmt.Errorf("aux symbol unavailable")
+ return rv, errors.New("aux symbol unavailable")
}
// Locate and return a pointer to the successor aux symbol.
pesymn := &f.COFFSymbols[idx+1]
diff --git a/src/encoding/asn1/marshal.go b/src/encoding/asn1/marshal.go
index c243349..6f84093 100644
--- a/src/encoding/asn1/marshal.go
+++ b/src/encoding/asn1/marshal.go
@@ -578,7 +578,7 @@

func makeField(v reflect.Value, params fieldParameters) (e encoder, err error) {
if !v.IsValid() {
- return nil, fmt.Errorf("asn1: cannot marshal nil value")
+ return nil, errors.New("asn1: cannot marshal nil value")
}
// If the field is an interface{} then recurse into it.
if v.Kind() == reflect.Interface && v.Type().NumMethod() == 0 {
diff --git a/src/encoding/gob/gobencdec_test.go b/src/encoding/gob/gobencdec_test.go
index 1d5dde2..b350ea3 100644
--- a/src/encoding/gob/gobencdec_test.go
+++ b/src/encoding/gob/gobencdec_test.go
@@ -773,7 +773,7 @@
t.Fatal("encode:", err)
}
dec := NewDecoder(b)
- err2 := fmt.Errorf("foo")
+ err2 := errors.New("foo")
err = dec.Decode(&err2)
if err != nil {
t.Fatal("decode:", err)
diff --git a/src/encoding/json/decode_test.go b/src/encoding/json/decode_test.go
index c2c036b..7edb338 100644
--- a/src/encoding/json/decode_test.go
+++ b/src/encoding/json/decode_test.go
@@ -279,11 +279,11 @@

func (b *byteWithMarshalJSON) UnmarshalJSON(data []byte) error {
if len(data) != 5 || data[0] != '"' || data[1] != 'Z' || data[4] != '"' {
- return fmt.Errorf("bad quoted string")
+ return errors.New("bad quoted string")
}
i, err := strconv.ParseInt(string(data[2:4]), 16, 8)
if err != nil {
- return fmt.Errorf("bad hex")
+ return errors.New("bad hex")
}
*b = byteWithMarshalJSON(i)
return nil
@@ -307,11 +307,11 @@

func (b *byteWithMarshalText) UnmarshalText(data []byte) error {
if len(data) != 3 || data[0] != 'Z' {
- return fmt.Errorf("bad quoted string")
+ return errors.New("bad quoted string")
}
i, err := strconv.ParseInt(string(data[1:3]), 16, 8)
if err != nil {
- return fmt.Errorf("bad hex")
+ return errors.New("bad hex")
}
*b = byteWithMarshalText(i)
return nil
@@ -335,11 +335,11 @@

func (b *intWithMarshalJSON) UnmarshalJSON(data []byte) error {
if len(data) != 5 || data[0] != '"' || data[1] != 'Z' || data[4] != '"' {
- return fmt.Errorf("bad quoted string")
+ return errors.New("bad quoted string")
}
i, err := strconv.ParseInt(string(data[2:4]), 16, 8)
if err != nil {
- return fmt.Errorf("bad hex")
+ return errors.New("bad hex")
}
*b = intWithMarshalJSON(i)
return nil
@@ -363,11 +363,11 @@

func (b *intWithMarshalText) UnmarshalText(data []byte) error {
if len(data) != 3 || data[0] != 'Z' {
- return fmt.Errorf("bad quoted string")
+ return errors.New("bad quoted string")
}
i, err := strconv.ParseInt(string(data[1:3]), 16, 8)
if err != nil {
- return fmt.Errorf("bad hex")
+ return errors.New("bad hex")
}
*b = intWithMarshalText(i)
return nil
@@ -424,7 +424,7 @@
{in: `{"X": [1,2,3], "Y": 4}`, ptr: new(T), out: T{Y: 4}, err: &UnmarshalTypeError{"array", reflect.TypeOf(""), 7, "T", "X"}},
{in: `{"X": 23}`, ptr: new(T), out: T{}, err: &UnmarshalTypeError{"number", reflect.TypeOf(""), 8, "T", "X"}}, {in: `{"x": 1}`, ptr: new(tx), out: tx{}},
{in: `{"x": 1}`, ptr: new(tx), out: tx{}},
- {in: `{"x": 1}`, ptr: new(tx), err: fmt.Errorf("json: unknown field \"x\""), disallowUnknownFields: true},
+ {in: `{"x": 1}`, ptr: new(tx), err: errors.New("json: unknown field \"x\""), disallowUnknownFields: true},
{in: `{"S": 23}`, ptr: new(W), out: W{}, err: &UnmarshalTypeError{"number", reflect.TypeOf(SS("")), 0, "W", "S"}},
{in: `{"F1":1,"F2":2,"F3":3}`, ptr: new(V), out: V{F1: float64(1), F2: int32(2), F3: Number("3")}},
{in: `{"F1":1,"F2":2,"F3":3}`, ptr: new(V), out: V{F1: Number("1"), F2: int32(2), F3: Number("3")}, useNumber: true},
@@ -440,13 +440,13 @@

// Z has a "-" tag.
{in: `{"Y": 1, "Z": 2}`, ptr: new(T), out: T{Y: 1}},
- {in: `{"Y": 1, "Z": 2}`, ptr: new(T), err: fmt.Errorf("json: unknown field \"Z\""), disallowUnknownFields: true},
+ {in: `{"Y": 1, "Z": 2}`, ptr: new(T), err: errors.New("json: unknown field \"Z\""), disallowUnknownFields: true},

{in: `{"alpha": "abc", "alphabet": "xyz"}`, ptr: new(U), out: U{Alphabet: "abc"}},
- {in: `{"alpha": "abc", "alphabet": "xyz"}`, ptr: new(U), err: fmt.Errorf("json: unknown field \"alphabet\""), disallowUnknownFields: true},
+ {in: `{"alpha": "abc", "alphabet": "xyz"}`, ptr: new(U), err: errors.New("json: unknown field \"alphabet\""), disallowUnknownFields: true},
{in: `{"alpha": "abc"}`, ptr: new(U), out: U{Alphabet: "abc"}},
{in: `{"alphabet": "xyz"}`, ptr: new(U), out: U{}},
- {in: `{"alphabet": "xyz"}`, ptr: new(U), err: fmt.Errorf("json: unknown field \"alphabet\""), disallowUnknownFields: true},
+ {in: `{"alphabet": "xyz"}`, ptr: new(U), err: errors.New("json: unknown field \"alphabet\""), disallowUnknownFields: true},

// syntax errors
{in: `{"X": "foo", "Y"}`, err: &SyntaxError{"invalid character '}' after object key", 17}},
@@ -647,7 +647,7 @@
{
in: `{"X": 1,"Y":2}`,
ptr: new(S5),
- err: fmt.Errorf("json: unknown field \"X\""),
+ err: errors.New("json: unknown field \"X\""),
disallowUnknownFields: true,
},
{
@@ -658,7 +658,7 @@
{
in: `{"X": 1,"Y":2}`,
ptr: new(S10),
- err: fmt.Errorf("json: unknown field \"X\""),
+ err: errors.New("json: unknown field \"X\""),
disallowUnknownFields: true,
},
{
@@ -872,7 +872,7 @@
"extra": true
}`,
ptr: new(Top),
- err: fmt.Errorf("json: unknown field \"extra\""),
+ err: errors.New("json: unknown field \"extra\""),
disallowUnknownFields: true,
},
{
@@ -899,7 +899,7 @@
"Q": 18
}`,
ptr: new(Top),
- err: fmt.Errorf("json: unknown field \"extra\""),
+ err: errors.New("json: unknown field \"extra\""),
disallowUnknownFields: true,
},
// issue 26444
@@ -2284,7 +2284,7 @@
in: `{"R":2,"Q":1}`,
ptr: new(S1),
out: &S1{R: 2},
- err: fmt.Errorf("json: cannot set embedded pointer to unexported struct: json.embed1"),
+ err: errors.New("json: cannot set embedded pointer to unexported struct: json.embed1"),
}, {
// The top level Q field takes precedence.
in: `{"Q":1}`,
@@ -2306,7 +2306,7 @@
in: `{"R":2,"Q":1}`,
ptr: new(S5),
out: &S5{R: 2},
- err: fmt.Errorf("json: cannot set embedded pointer to unexported struct: json.embed3"),
+ err: errors.New("json: cannot set embedded pointer to unexported struct: json.embed3"),
}, {
// Issue 24152, ensure decodeState.indirect does not panic.
in: `{"embed1": {"Q": 1}}`,
diff --git a/src/encoding/xml/marshal.go b/src/encoding/xml/marshal.go
index 7792ac7..9ab8ec4 100644
--- a/src/encoding/xml/marshal.go
+++ b/src/encoding/xml/marshal.go
@@ -8,6 +8,7 @@
"bufio"
"bytes"
"encoding"
+ "errors"
"fmt"
"io"
"reflect"
@@ -215,7 +216,7 @@
escapeText(p, t, false)
case Comment:
if bytes.Contains(t, endComment) {
- return fmt.Errorf("xml: EncodeToken of Comment containing --> marker")
+ return errors.New("xml: EncodeToken of Comment containing --> marker")
}
p.WriteString("<!--")
p.Write(t)
@@ -225,13 +226,13 @@
// First token to be encoded which is also a ProcInst with target of xml
// is the xml declaration. The only ProcInst where target of xml is allowed.
if t.Target == "xml" && p.Buffered() != 0 {
- return fmt.Errorf("xml: EncodeToken of ProcInst xml target only valid for xml declaration, first token encoded")
+ return errors.New("xml: EncodeToken of ProcInst xml target only valid for xml declaration, first token encoded")
}
if !isNameString(t.Target) {
- return fmt.Errorf("xml: EncodeToken of ProcInst with invalid Target")
+ return errors.New("xml: EncodeToken of ProcInst with invalid Target")
}
if bytes.Contains(t.Inst, endProcInst) {
- return fmt.Errorf("xml: EncodeToken of ProcInst containing ?> marker")
+ return errors.New("xml: EncodeToken of ProcInst containing ?> marker")
}
p.WriteString("<?")
p.WriteString(t.Target)
@@ -242,13 +243,13 @@
p.WriteString("?>")
case Directive:
if !isValidDirective(t) {
- return fmt.Errorf("xml: EncodeToken of Directive containing wrong < or > markers")
+ return errors.New("xml: EncodeToken of Directive containing wrong < or > markers")
}
p.WriteString("<!")
p.Write(t)
p.WriteString(">")
default:
- return fmt.Errorf("xml: EncodeToken of invalid token type")
+ return errors.New("xml: EncodeToken of invalid token type")

}
return p.cachedWriteError()
@@ -407,7 +408,7 @@
// If val was obtained from a struct field, finfo must have its details.
func (p *printer) marshalValue(val reflect.Value, finfo *fieldInfo, startTemplate *StartElement) error {
if startTemplate != nil && startTemplate.Name.Local == "" {
- return fmt.Errorf("xml: EncodeElement of StartElement with missing name")
+ return errors.New("xml: EncodeElement of StartElement with missing name")
}

if !val.IsValid() {
@@ -695,7 +696,7 @@
// writeStart writes the given start element.
func (p *printer) writeStart(start *StartElement) error {
if start.Name.Local == "" {
- return fmt.Errorf("xml: start tag with no name")
+ return errors.New("xml: start tag with no name")
}

p.tags = append(p.tags, start.Name)
@@ -733,7 +734,7 @@

func (p *printer) writeEnd(name Name) error {
if name.Local == "" {
- return fmt.Errorf("xml: end tag with no name")
+ return errors.New("xml: end tag with no name")
}
if len(p.tags) == 0 || p.tags[len(p.tags)-1].Local == "" {
return fmt.Errorf("xml: end tag </%s> without start tag", name.Local)
@@ -920,7 +921,7 @@
panic("can't happen")
}
if dashDash {
- return fmt.Errorf(`xml: comments must not contain "--"`)
+ return errors.New(`xml: comments must not contain "--"`)
}
if dashLast {
// "--->" is invalid grammar. Make it "- -->"
diff --git a/src/encoding/xml/xml_test.go b/src/encoding/xml/xml_test.go
index 8f0d97b..1368977ae 100644
--- a/src/encoding/xml/xml_test.go
+++ b/src/encoding/xml/xml_test.go
@@ -6,6 +6,7 @@

import (
"bytes"
+ "errors"
"fmt"
"io"
"reflect"
@@ -879,7 +880,7 @@
// Writer whose Write method always returns an error.
type errWriter struct{}

-func (errWriter) Write(p []byte) (n int, err error) { return 0, fmt.Errorf("unwritable") }
+func (errWriter) Write(p []byte) (n int, err error) { return 0, errors.New("unwritable") }

func TestEscapeTextIOErrors(t *testing.T) {
expectErr := "unwritable"
diff --git a/src/flag/flag_test.go b/src/flag/flag_test.go
index d5c443d..c5431ec 100644
--- a/src/flag/flag_test.go
+++ b/src/flag/flag_test.go
@@ -6,6 +6,7 @@

import (
"bytes"
+ "errors"
. "flag"
"fmt"
"internal/testenv"
@@ -290,7 +291,7 @@
flags = NewFlagSet("test", ContinueOnError)
flags.SetOutput(io.Discard)
flags.Func("v", "usage", func(s string) error {
- return fmt.Errorf("test error")
+ return errors.New("test error")
})
// flag not set, so no error
if err := flags.Parse(nil); err != nil {
diff --git a/src/go/doc/doc.go b/src/go/doc/doc.go
index 5ab854d..e5978fb 100644
--- a/src/go/doc/doc.go
+++ b/src/go/doc/doc.go
@@ -6,6 +6,7 @@
package doc

import (
+ "errors"
"fmt"
"go/ast"
"go/token"
@@ -160,7 +161,7 @@
func NewFromFiles(fset *token.FileSet, files []*ast.File, importPath string, opts ...any) (*Package, error) {
// Check for invalid API usage.
if fset == nil {
- panic(fmt.Errorf("doc.NewFromFiles: no token.FileSet provided (fset == nil)"))
+ panic(errors.New("doc.NewFromFiles: no token.FileSet provided (fset == nil)"))
}
var mode Mode
switch len(opts) { // There can only be 0 or 1 options, so a simple switch works for now.
@@ -169,11 +170,11 @@
case 1:
m, ok := opts[0].(Mode)
if !ok {
- panic(fmt.Errorf("doc.NewFromFiles: option argument type must be doc.Mode"))
+ panic(errors.New("doc.NewFromFiles: option argument type must be doc.Mode"))
}
mode = m
default:
- panic(fmt.Errorf("doc.NewFromFiles: there must not be more than 1 option argument"))
+ panic(errors.New("doc.NewFromFiles: there must not be more than 1 option argument"))
}

// Collect .go and _test.go files.
diff --git a/src/go/internal/gccgoimporter/ar.go b/src/go/internal/gccgoimporter/ar.go
index 443aa26..b9b00eb 100644
--- a/src/go/internal/gccgoimporter/ar.go
+++ b/src/go/internal/gccgoimporter/ar.go
@@ -146,7 +146,7 @@
}
}

- return nil, fmt.Errorf(".go_export not found in this archive")
+ return nil, errors.New(".go_export not found in this archive")
}

// readerAtFromSeeker turns an io.ReadSeeker into an io.ReaderAt.
diff --git a/src/go/internal/gcimporter/exportdata.go b/src/go/internal/gcimporter/exportdata.go
index c12e459..5418844 100644
--- a/src/go/internal/gcimporter/exportdata.go
+++ b/src/go/internal/gcimporter/exportdata.go
@@ -8,6 +8,7 @@

import (
"bufio"
+ "errors"
"fmt"
"io"
"strconv"
@@ -28,7 +29,7 @@
s := strings.TrimSpace(string(hdr[16+12+6+6+8:][:10]))
size, err = strconv.Atoi(s)
if err != nil || hdr[len(hdr)-2] != '`' || hdr[len(hdr)-1] != '\n' {
- err = fmt.Errorf("invalid archive header")
+ err = errors.New("invalid archive header")
return
}
name = strings.TrimSpace(string(hdr[:16]))
@@ -58,7 +59,7 @@

// First entry should be __.PKGDEF.
if name != "__.PKGDEF" {
- err = fmt.Errorf("go archive is missing __.PKGDEF")
+ err = errors.New("go archive is missing __.PKGDEF")
return
}

@@ -73,7 +74,7 @@
// Now at __.PKGDEF in archive or still at beginning of file.
// Either way, line should begin with "go object ".
if !strings.HasPrefix(string(line), "go object ") {
- err = fmt.Errorf("not a Go object file")
+ err = errors.New("not a Go object file")
return
}

diff --git a/src/go/types/check_test.go b/src/go/types/check_test.go
index 592ced4..43b6214 100644
--- a/src/go/types/check_test.go
+++ b/src/go/types/check_test.go
@@ -24,6 +24,7 @@

import (
"bytes"
+ "errors"
"flag"
"fmt"
"go/ast"
@@ -217,7 +218,7 @@
}
end := bytes.Index(src, []byte("\n"))
if end < 0 || end > maxLen {
- return fmt.Errorf("flags comment line too long")
+ return errors.New("flags comment line too long")
}

return flags.Parse(strings.Fields(string(src[:end])))
diff --git a/src/go/types/resolver.go b/src/go/types/resolver.go
index ae21c6d..c5e0b7e 100644
--- a/src/go/types/resolver.go
+++ b/src/go/types/resolver.go
@@ -5,6 +5,7 @@
package types

import (
+ "errors"
"fmt"
"go/ast"
"go/constant"
@@ -87,7 +88,7 @@
return "", err
}
if s == "" {
- return "", fmt.Errorf("empty string")
+ return "", errors.New("empty string")
}
const illegalChars = `!"#$%&'()*,:;<=>?[\]^{|}` + "`\uFFFD"
for _, r := range s {
@@ -152,7 +153,7 @@
// ordinary import
var err error
if importer := check.conf.Importer; importer == nil {
- err = fmt.Errorf("Config.Importer not installed")
+ err = errors.New("Config.Importer not installed")
} else if importerFrom, ok := importer.(ImporterFrom); ok {
imp, err = importerFrom.ImportFrom(path, dir, 0)
if imp == nil && err == nil {
diff --git a/src/go/types/version.go b/src/go/types/version.go
index 1546941..7e6d873 100644
--- a/src/go/types/version.go
+++ b/src/go/types/version.go
@@ -5,7 +5,7 @@
package types

import (
- "fmt"
+ "errors"
"go/ast"
"go/token"
"regexp"
@@ -67,7 +67,7 @@
}
matches := goVersionRx.FindStringSubmatch(s)
if matches == nil {
- err = fmt.Errorf(`should be something like "go1.12"`)
+ err = errors.New(`should be something like "go1.12"`)
return
}
v.major, err = strconv.Atoi(matches[1])
diff --git a/src/html/template/template.go b/src/html/template/template.go
index 952f529..f220729 100644
--- a/src/html/template/template.go
+++ b/src/html/template/template.go
@@ -5,6 +5,7 @@
package template

import (
+ "errors"
"fmt"
"io"
"io/fs"
@@ -31,7 +32,7 @@
}

// escapeOK is a sentinel value used to indicate valid escaping.
-var escapeOK = fmt.Errorf("template escaped correctly")
+var escapeOK = errors.New("template escaped correctly")

// nameSpace is the data structure shared by all templates in an association.
type nameSpace struct {
@@ -87,7 +88,7 @@
t.nameSpace.mu.Lock()
defer t.nameSpace.mu.Unlock()
if t.nameSpace.escaped {
- return fmt.Errorf("html/template: cannot Parse after Execute")
+ return errors.New("html/template: cannot Parse after Execute")
}
return nil
}
@@ -403,7 +404,7 @@

if len(filenames) == 0 {
// Not really a problem, but be consistent.
- return nil, fmt.Errorf("html/template: no files named in call to ParseFiles")
+ return nil, errors.New("html/template: no files named in call to ParseFiles")
}
for _, filename := range filenames {
name, b, err := readFile(filename)
diff --git a/src/image/gif/reader.go b/src/image/gif/reader.go
index 9e8268c..1aedf45 100644
--- a/src/image/gif/reader.go
+++ b/src/image/gif/reader.go
@@ -252,7 +252,7 @@

case sTrailer:
if len(d.image) == 0 {
- return fmt.Errorf("gif: missing image data")
+ return errors.New("gif: missing image data")
}
return nil

diff --git a/src/internal/buildcfg/cfg.go b/src/internal/buildcfg/cfg.go
index 1066d0c..55281e3 100644
--- a/src/internal/buildcfg/cfg.go
+++ b/src/internal/buildcfg/cfg.go
@@ -12,6 +12,7 @@
package buildcfg

import (
+ "errors"
"fmt"
"os"
"path/filepath"
@@ -63,7 +64,7 @@
case "v4":
return 4
}
- Error = fmt.Errorf("invalid GOAMD64: must be v1, v2, v3, v4")
+ Error = errors.New("invalid GOAMD64: must be v1, v2, v3, v4")
return int(defaultGOAMD64[len("v")] - '0')
}

@@ -81,7 +82,7 @@
case "7":
return 7
}
- Error = fmt.Errorf("invalid GOARM: must be 5, 6, 7")
+ Error = errors.New("invalid GOARM: must be 5, 6, 7")
return int(def[0] - '0')
}

@@ -90,7 +91,7 @@
case "hardfloat", "softfloat":
return v
}
- Error = fmt.Errorf("invalid GOMIPS: must be hardfloat, softfloat")
+ Error = errors.New("invalid GOMIPS: must be hardfloat, softfloat")
return defaultGOMIPS
}

@@ -99,7 +100,7 @@
case "hardfloat", "softfloat":
return v
}
- Error = fmt.Errorf("invalid GOMIPS64: must be hardfloat, softfloat")
+ Error = errors.New("invalid GOMIPS64: must be hardfloat, softfloat")
return defaultGOMIPS64
}

@@ -110,7 +111,7 @@
case "power9":
return 9
}
- Error = fmt.Errorf("invalid GOPPC64: must be power8, power9")
+ Error = errors.New("invalid GOPPC64: must be power8, power9")
return int(defaultGOPPC64[len("power")] - '0')
}

diff --git a/src/internal/buildcfg/exp.go b/src/internal/buildcfg/exp.go
index 87b1686..12d4d69 100644
--- a/src/internal/buildcfg/exp.go
+++ b/src/internal/buildcfg/exp.go
@@ -5,6 +5,7 @@
package buildcfg

import (
+ "errors"
"fmt"
"reflect"
"strings"
@@ -134,7 +135,7 @@
}
// Check regabi dependencies.
if flags.RegabiArgs && !flags.RegabiWrappers {
- return nil, fmt.Errorf("GOEXPERIMENT regabiargs requires regabiwrappers")
+ return nil, errors.New("GOEXPERIMENT regabiargs requires regabiwrappers")
}
return flags, nil
}
diff --git a/src/internal/fuzz/encoding.go b/src/internal/fuzz/encoding.go
index c95d9e0..e5a3d91 100644
--- a/src/internal/fuzz/encoding.go
+++ b/src/internal/fuzz/encoding.go
@@ -6,6 +6,7 @@

import (
"bytes"
+ "errors"
"fmt"
"go/ast"
"go/parser"
@@ -100,11 +101,11 @@
// unmarshalCorpusFile decodes corpus bytes into their respective values.
func unmarshalCorpusFile(b []byte) ([]any, error) {
if len(b) == 0 {
- return nil, fmt.Errorf("cannot unmarshal empty string")
+ return nil, errors.New("cannot unmarshal empty string")
}
lines := bytes.Split(b, []byte("\n"))
if len(lines) < 2 {
- return nil, fmt.Errorf("must include version and at least one value")
+ return nil, errors.New("must include version and at least one value")
}
if string(lines[0]) != encVersion1 {
return nil, fmt.Errorf("unknown encoding version: %s", lines[0])
@@ -132,7 +133,7 @@
}
call, ok := expr.(*ast.CallExpr)
if !ok {
- return nil, fmt.Errorf("expected call expression")
+ return nil, errors.New("expected call expression")
}
if len(call.Args) != 1 {
return nil, fmt.Errorf("expected call expression with 1 argument; got %d", len(call.Args))
@@ -141,15 +142,15 @@

if arrayType, ok := call.Fun.(*ast.ArrayType); ok {
if arrayType.Len != nil {
- return nil, fmt.Errorf("expected []byte or primitive type")
+ return nil, errors.New("expected []byte or primitive type")
}
elt, ok := arrayType.Elt.(*ast.Ident)
if !ok || elt.Name != "byte" {
- return nil, fmt.Errorf("expected []byte")
+ return nil, errors.New("expected []byte")
}
lit, ok := arg.(*ast.BasicLit)
if !ok || lit.Kind != token.STRING {
- return nil, fmt.Errorf("string literal required for type []byte")
+ return nil, errors.New("string literal required for type []byte")
}
s, err := strconv.Unquote(lit.Value)
if err != nil {
@@ -162,7 +163,7 @@
if selector, ok := call.Fun.(*ast.SelectorExpr); ok {
xIdent, ok := selector.X.(*ast.Ident)
if !ok || xIdent.Name != "math" {
- return nil, fmt.Errorf("invalid selector type")
+ return nil, errors.New("invalid selector type")
}
switch selector.Sel.Name {
case "Float64frombits":
@@ -170,24 +171,24 @@
case "Float32frombits":
idType = &ast.Ident{Name: "float32-bits"}
default:
- return nil, fmt.Errorf("invalid selector type")
+ return nil, errors.New("invalid selector type")
}
} else {
idType, ok = call.Fun.(*ast.Ident)
if !ok {
- return nil, fmt.Errorf("expected []byte or primitive type")
+ return nil, errors.New("expected []byte or primitive type")
}
if idType.Name == "bool" {
id, ok := arg.(*ast.Ident)
if !ok {
- return nil, fmt.Errorf("malformed bool")
+ return nil, errors.New("malformed bool")
}
if id.Name == "true" {
return true, nil
} else if id.Name == "false" {
return false, nil
} else {
- return nil, fmt.Errorf("true or false required for type bool")
+ return nil, errors.New("true or false required for type bool")
}
}
}
@@ -207,7 +208,7 @@
kind = lit.Kind
case *ast.Ident:
if lit.Name != "Inf" {
- return nil, fmt.Errorf("expected operation on int or float type")
+ return nil, errors.New("expected operation on int or float type")
}
if op.Op == token.SUB {
val = "-Inf"
@@ -216,7 +217,7 @@
}
kind = token.FLOAT
default:
- return nil, fmt.Errorf("expected operation on int or float type")
+ return nil, errors.New("expected operation on int or float type")
}
} else {
switch lit := arg.(type) {
@@ -224,18 +225,18 @@
val, kind = lit.Value, lit.Kind
case *ast.Ident:
if lit.Name != "NaN" {
- return nil, fmt.Errorf("literal value required for primitive type")
+ return nil, errors.New("literal value required for primitive type")
}
val, kind = "NaN", token.FLOAT
default:
- return nil, fmt.Errorf("literal value required for primitive type")
+ return nil, errors.New("literal value required for primitive type")
}
}

switch typ := idType.Name; typ {
case "string":
if kind != token.STRING {
- return nil, fmt.Errorf("string literal value required for type string")
+ return nil, errors.New("string literal value required for type string")
}
return strconv.Unquote(val)
case "byte", "rune":
@@ -248,11 +249,11 @@
}
}
if kind != token.CHAR {
- return nil, fmt.Errorf("character literal required for byte/rune types")
+ return nil, errors.New("character literal required for byte/rune types")
}
n := len(val)
if n < 2 {
- return nil, fmt.Errorf("malformed character literal, missing single quotes")
+ return nil, errors.New("malformed character literal, missing single quotes")
}
code, _, _, err := strconv.UnquoteChar(val[1:n-1], '\'')
if err != nil {
@@ -262,33 +263,33 @@
return code, nil
}
if code >= 256 {
- return nil, fmt.Errorf("can only encode single byte to a byte type")
+ return nil, errors.New("can only encode single byte to a byte type")
}
return byte(code), nil
case "int", "int8", "int16", "int32", "int64":
if kind != token.INT {
- return nil, fmt.Errorf("integer literal required for int types")
+ return nil, errors.New("integer literal required for int types")
}
return parseInt(val, typ)
case "uint", "uint8", "uint16", "uint32", "uint64":
if kind != token.INT {
- return nil, fmt.Errorf("integer literal required for uint types")
+ return nil, errors.New("integer literal required for uint types")
}
return parseUint(val, typ)
case "float32":
if kind != token.FLOAT && kind != token.INT {
- return nil, fmt.Errorf("float or integer literal required for float32 type")
+ return nil, errors.New("float or integer literal required for float32 type")
}
v, err := strconv.ParseFloat(val, 32)
return float32(v), err
case "float64":
if kind != token.FLOAT && kind != token.INT {
- return nil, fmt.Errorf("float or integer literal required for float64 type")
+ return nil, errors.New("float or integer literal required for float64 type")
}
return strconv.ParseFloat(val, 64)
case "float32-bits":
if kind != token.INT {
- return nil, fmt.Errorf("integer literal required for math.Float32frombits type")
+ return nil, errors.New("integer literal required for math.Float32frombits type")
}
bits, err := parseUint(val, "uint32")
if err != nil {
@@ -297,7 +298,7 @@
return math.Float32frombits(bits.(uint32)), nil
case "float64-bits":
if kind != token.FLOAT && kind != token.INT {
- return nil, fmt.Errorf("integer literal required for math.Float64frombits type")
+ return nil, errors.New("integer literal required for math.Float64frombits type")
}
bits, err := parseUint(val, "uint64")
if err != nil {
@@ -305,7 +306,7 @@
}
return math.Float64frombits(bits.(uint64)), nil
default:
- return nil, fmt.Errorf("expected []byte or primitive type")
+ return nil, errors.New("expected []byte or primitive type")
}
}

diff --git a/src/internal/fuzz/sys_posix.go b/src/internal/fuzz/sys_posix.go
index fec6054..8d8ba7a 100644
--- a/src/internal/fuzz/sys_posix.go
+++ b/src/internal/fuzz/sys_posix.go
@@ -7,7 +7,7 @@
package fuzz

import (
- "fmt"
+ "errors"
"os"
"os/exec"
"syscall"
@@ -67,7 +67,7 @@
}
size := int(fi.Size())
if int64(size) != fi.Size() {
- return workerComm{}, fmt.Errorf("fuzz temp file exceeds maximum size")
+ return workerComm{}, errors.New("fuzz temp file exceeds maximum size")
}
removeOnClose := false
mem, err := sharedMemMapFile(memFile, size, removeOnClose)
diff --git a/src/internal/fuzz/sys_windows.go b/src/internal/fuzz/sys_windows.go
index 9c006b0..eaf922d 100644
--- a/src/internal/fuzz/sys_windows.go
+++ b/src/internal/fuzz/sys_windows.go
@@ -102,7 +102,7 @@
func getWorkerComm() (comm workerComm, err error) {
v := os.Getenv("GO_TEST_FUZZ_WORKER_HANDLES")
if v == "" {
- return workerComm{}, fmt.Errorf("GO_TEST_FUZZ_WORKER_HANDLES not set")
+ return workerComm{}, errors.New("GO_TEST_FUZZ_WORKER_HANDLES not set")
}
var fuzzInFD, fuzzOutFD uintptr
var memName string
@@ -122,7 +122,7 @@
}
size := int(fi.Size())
if int64(size) != fi.Size() {
- return workerComm{}, fmt.Errorf("fuzz temp file exceeds maximum size")
+ return workerComm{}, errors.New("fuzz temp file exceeds maximum size")
}
removeOnClose := false
mem, err := sharedMemMapFile(tmpFile, size, removeOnClose)
diff --git a/src/internal/fuzz/worker.go b/src/internal/fuzz/worker.go
index 6e4c4e2..a0bf5067 100644
--- a/src/internal/fuzz/worker.go
+++ b/src/internal/fuzz/worker.go
@@ -267,7 +267,7 @@
}

if input.crasherMsg != "" && resp.Err == "" {
- return fuzzResult{}, fmt.Errorf("attempted to minimize a crash but could not reproduce")
+ return fuzzResult{}, errors.New("attempted to minimize a crash but could not reproduce")
}

return fuzzResult{
diff --git a/src/internal/profile/merge.go b/src/internal/profile/merge.go
index 3ea7d4c..a2bf5b1 100644
--- a/src/internal/profile/merge.go
+++ b/src/internal/profile/merge.go
@@ -5,6 +5,7 @@
package profile

import (
+ "errors"
"fmt"
"sort"
"strconv"
@@ -20,7 +21,7 @@
// profile.TimeNanos will be the earliest nonzero one.
func Merge(srcs []*Profile) (*Profile, error) {
if len(srcs) == 0 {
- return nil, fmt.Errorf("no profiles to merge")
+ return nil, errors.New("no profiles to merge")
}
p, err := combineHeaders(srcs)
if err != nil {
diff --git a/src/internal/profile/profile.go b/src/internal/profile/profile.go
index 29568aa..588312f 100644
--- a/src/internal/profile/profile.go
+++ b/src/internal/profile/profile.go
@@ -10,6 +10,7 @@
import (
"bytes"
"compress/gzip"
+ "errors"
"fmt"
"io"
"regexp"
@@ -153,8 +154,8 @@
return p, nil
}

-var errUnrecognized = fmt.Errorf("unrecognized profile format")
-var errMalformed = fmt.Errorf("malformed profile format")
+var errUnrecognized = errors.New("unrecognized profile format")
+var errMalformed = errors.New("malformed profile format")

func parseLegacy(data []byte) (*Profile, error) {
parsers := []func([]byte) (*Profile, error){
@@ -233,7 +234,7 @@
// Check that sample values are consistent
sampleLen := len(p.SampleType)
if sampleLen == 0 && len(p.Sample) != 0 {
- return fmt.Errorf("missing sample type information")
+ return errors.New("missing sample type information")
}
for _, s := range p.Sample {
if len(s.Value) != sampleLen {
@@ -246,7 +247,7 @@
mappings := make(map[uint64]*Mapping, len(p.Mapping))
for _, m := range p.Mapping {
if m.ID == 0 {
- return fmt.Errorf("found mapping with reserved ID=0")
+ return errors.New("found mapping with reserved ID=0")
}
if mappings[m.ID] != nil {
return fmt.Errorf("multiple mappings with same id: %d", m.ID)
@@ -256,7 +257,7 @@
functions := make(map[uint64]*Function, len(p.Function))
for _, f := range p.Function {
if f.ID == 0 {
- return fmt.Errorf("found function with reserved ID=0")
+ return errors.New("found function with reserved ID=0")
}
if functions[f.ID] != nil {
return fmt.Errorf("multiple functions with same id: %d", f.ID)
@@ -266,7 +267,7 @@
locations := make(map[uint64]*Location, len(p.Location))
for _, l := range p.Location {
if l.ID == 0 {
- return fmt.Errorf("found location with reserved id=0")
+ return errors.New("found location with reserved id=0")
}
if locations[l.ID] != nil {
return fmt.Errorf("multiple locations with same id: %d", l.ID)
diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go
index 6ef889b..60fd998 100644
--- a/src/internal/testenv/testenv.go
+++ b/src/internal/testenv/testenv.go
@@ -137,7 +137,7 @@
parent := filepath.Dir(dir)
if parent == dir {
// dir is either "." or only a volume name.
- gorootErr = fmt.Errorf("failed to locate GOROOT/src in any parent directory")
+ gorootErr = errors.New("failed to locate GOROOT/src in any parent directory")
return
}

diff --git a/src/internal/trace/order.go b/src/internal/trace/order.go
index 36ed58d..a81adaf 100644
--- a/src/internal/trace/order.go
+++ b/src/internal/trace/order.go
@@ -5,7 +5,7 @@
package trace

import (
- "fmt"
+ "errors"
"sort"
)

@@ -83,7 +83,7 @@
}
}
if len(frontier) == 0 {
- return nil, fmt.Errorf("no consistent ordering of events possible")
+ return nil, errors.New("no consistent ordering of events possible")
}
sort.Sort(orderEventList(frontier))
f := frontier[0]
@@ -125,7 +125,7 @@
}
block := lastSysBlock[ev.G]
if block == 0 {
- return nil, fmt.Errorf("stray syscall exit")
+ return nil, errors.New("stray syscall exit")
}
if ts < block {
return nil, ErrTimeOrder
diff --git a/src/internal/trace/parser.go b/src/internal/trace/parser.go
index 254f201..e22f674 100644
--- a/src/internal/trace/parser.go
+++ b/src/internal/trace/parser.go
@@ -7,6 +7,7 @@
import (
"bufio"
"bytes"
+ "errors"
"fmt"
"io"
"math/rand"
@@ -92,7 +93,7 @@
return ParseResult{}, err
}
if ver < 1007 && bin == "" {
- return ParseResult{}, fmt.Errorf("for traces produced by go 1.6 or below, the binary argument must be provided")
+ return ParseResult{}, errors.New("for traces produced by go 1.6 or below, the binary argument must be provided")
}
return res, nil
}
@@ -291,13 +292,13 @@
// and returns parsed version as 1007.
func parseHeader(buf []byte) (int, error) {
if len(buf) != 16 {
- return 0, fmt.Errorf("bad header length")
+ return 0, errors.New("bad header length")
}
if buf[0] != 'g' || buf[1] != 'o' || buf[2] != ' ' ||
buf[3] < '1' || buf[3] > '9' ||
buf[4] != '.' ||
buf[5] < '1' || buf[5] > '9' {
- return 0, fmt.Errorf("not a trace file")
+ return 0, errors.New("not a trace file")
}
ver := int(buf[5] - '0')
i := 0
@@ -306,7 +307,7 @@
}
ver += int(buf[3]-'0') * 1000
if !bytes.Equal(buf[6+i:], []byte(" trace\x00\x00\x00\x00")[:10-i]) {
- return 0, fmt.Errorf("not a trace file")
+ return 0, errors.New("not a trace file")
}
return ver, nil
}
@@ -453,11 +454,11 @@
}
}
if len(batches) == 0 {
- err = fmt.Errorf("trace is empty")
+ err = errors.New("trace is empty")
return
}
if ticksPerSec == 0 {
- err = fmt.Errorf("no EvFrequency event")
+ err = errors.New("no EvFrequency event")
return
}
if BreakTimestampsForTesting {
@@ -554,7 +555,7 @@

// ErrTimeOrder is returned by Parse when the trace contains
// time stamps that do not respect actual event ordering.
-var ErrTimeOrder = fmt.Errorf("time stamps out of order")
+var ErrTimeOrder = errors.New("time stamps out of order")

// postProcessTrace does inter-event verification and information restoration.
// The resulting trace is guaranteed to be consistent
diff --git a/src/internal/xcoff/ar.go b/src/internal/xcoff/ar.go
index 0fb410f..e8055cb 100644
--- a/src/internal/xcoff/ar.go
+++ b/src/internal/xcoff/ar.go
@@ -6,6 +6,7 @@

import (
"encoding/binary"
+ "errors"
"fmt"
"io"
"os"
@@ -117,7 +118,7 @@
case AIAMAGBIG:
arch.magic = string(magic[:])
case AIAMAG:
- return nil, fmt.Errorf("small AIX archive not supported")
+ return nil, errors.New("small AIX archive not supported")
default:
return nil, fmt.Errorf("unrecognised archive magic: 0x%x", magic)
}
@@ -194,7 +195,7 @@
return nil, err
}
if string(fmag[:]) != AIAFMAG {
- return nil, fmt.Errorf("AIAFMAG not found after member header")
+ return nil, errors.New("AIAFMAG not found after member header")
}

fileoff += 2 // Add the two bytes of AIAFMAG
diff --git a/src/internal/xcoff/file.go b/src/internal/xcoff/file.go
index 05e4fd5..62725ff 100644
--- a/src/internal/xcoff/file.go
+++ b/src/internal/xcoff/file.go
@@ -8,6 +8,7 @@
import (
"debug/dwarf"
"encoding/binary"
+ "errors"
"fmt"
"io"
"os"
@@ -199,7 +200,7 @@
}

if symptr == 0 || nsyms <= 0 {
- return nil, fmt.Errorf("no symbol table")
+ return nil, errors.New("no symbol table")
}

// Read string table (located right after symbol table).
diff --git a/src/io/io_test.go b/src/io/io_test.go
index 3088460..d327d5b 100644
--- a/src/io/io_test.go
+++ b/src/io/io_test.go
@@ -7,7 +7,6 @@
import (
"bytes"
"errors"
- "fmt"
. "io"
"strings"
"testing"
@@ -274,7 +273,7 @@

func TestReadAtLeastWithDataAndError(t *testing.T) {
var rb dataAndErrorBuffer
- rb.err = fmt.Errorf("fake error")
+ rb.err = errors.New("fake error")
testReadAtLeast(t, &rb)
}

diff --git a/src/math/big/floatconv.go b/src/math/big/floatconv.go
index 57b7df3..c985955 100644
--- a/src/math/big/floatconv.go
+++ b/src/math/big/floatconv.go
@@ -7,6 +7,7 @@
package big

import (
+ "errors"
"fmt"
"io"
"strings"
@@ -126,7 +127,7 @@
z.exp = int32(exp2)
f = z
} else {
- err = fmt.Errorf("exponent overflow")
+ err = errors.New("exponent overflow")
return
}

diff --git a/src/mime/multipart/multipart.go b/src/mime/multipart/multipart.go
index 81bf722..2de955d 100644
--- a/src/mime/multipart/multipart.go
+++ b/src/mime/multipart/multipart.go
@@ -15,6 +15,7 @@
import (
"bufio"
"bytes"
+ "errors"
"fmt"
"io"
"mime"
@@ -328,7 +329,7 @@
r.currentPart.Close()
}
if string(r.dashBoundary) == "--" {
- return nil, fmt.Errorf("multipart: boundary is empty")
+ return nil, errors.New("multipart: boundary is empty")
}
expectNewPart := false
for {
diff --git a/src/net/dnsclient_unix_test.go b/src/net/dnsclient_unix_test.go
index 415c53e..d7ea8ad 100644
--- a/src/net/dnsclient_unix_test.go
+++ b/src/net/dnsclient_unix_test.go
@@ -1234,7 +1234,7 @@
case resolveOK:
// Handle below.
case resolveOpError:
- return dnsmessage.Message{}, &OpError{Op: "write", Err: fmt.Errorf("socket on fire")}
+ return dnsmessage.Message{}, &OpError{Op: "write", Err: errors.New("socket on fire")}
case resolveServfail:
return dnsmessage.Message{
Header: dnsmessage.Header{
diff --git a/src/net/http/client_test.go b/src/net/http/client_test.go
index e91d526..d21744c 100644
--- a/src/net/http/client_test.go
+++ b/src/net/http/client_test.go
@@ -44,7 +44,7 @@
for {
n, err := r.Read(buf)
if n == 0 && err == nil {
- return nil, fmt.Errorf("Read: n=0 with err=nil")
+ return nil, errors.New("Read: n=0 with err=nil")
}
b = append(b, buf[:n]...)
if err == io.EOF {
@@ -1507,7 +1507,7 @@
// Issue 15577: don't assume the roundtripper's response populates its Request field.
func TestClientRedirectResponseWithoutRequest(t *testing.T) {
c := &Client{
- CheckRedirect: func(*Request, []*Request) error { return fmt.Errorf("no redirects!") },
+ CheckRedirect: func(*Request, []*Request) error { return errors.New("no redirects!") },
Transport: issue15577Tripper{},
}
// Check that this doesn't crash:
diff --git a/src/net/http/clientserver_test.go b/src/net/http/clientserver_test.go
index 71b2a32..9e2424c 100644
--- a/src/net/http/clientserver_test.go
+++ b/src/net/http/clientserver_test.go
@@ -12,6 +12,7 @@
"crypto/rand"
"crypto/sha1"
"crypto/tls"
+ "errors"
"fmt"
"hash"
"io"
@@ -1220,7 +1221,7 @@
return fmt.Errorf("want no log output; got: %s", gotLog)
}
if gotLog == "" {
- return fmt.Errorf("wanted a stack trace logged; got nothing")
+ return errors.New("wanted a stack trace logged; got nothing")
}
if !strings.Contains(gotLog, "created by ") && strings.Count(gotLog, "\n") < 6 {
return fmt.Errorf("output doesn't look like a panic stack trace. Got: %s", gotLog)
diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go
index e955135..c20eb6a 100644
--- a/src/net/http/h2_bundle.go
+++ b/src/net/http/h2_bundle.go
@@ -3970,7 +3970,7 @@
}
}
if !haveRequired {
- return fmt.Errorf("http2: TLSConfig.CipherSuites is missing an HTTP/2-required AES_128_GCM_SHA256 cipher (need at least one of TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 or TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256)")
+ return errors.New("http2: TLSConfig.CipherSuites is missing an HTTP/2-required AES_128_GCM_SHA256 cipher (need at least one of TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 or TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256)")
}
}

diff --git a/src/net/http/httputil/reverseproxy.go b/src/net/http/httputil/reverseproxy.go
index b724413..71e3c17 100644
--- a/src/net/http/httputil/reverseproxy.go
+++ b/src/net/http/httputil/reverseproxy.go
@@ -8,6 +8,7 @@

import (
"context"
+ "errors"
"fmt"
"io"
"log"
@@ -581,7 +582,7 @@
}
backConn, ok := res.Body.(io.ReadWriteCloser)
if !ok {
- p.getErrorHandler()(rw, req, fmt.Errorf("internal error: 101 switching protocols response with non-writable body"))
+ p.getErrorHandler()(rw, req, errors.New("internal error: 101 switching protocols response with non-writable body"))
return
}

diff --git a/src/net/http/httputil/reverseproxy_test.go b/src/net/http/httputil/reverseproxy_test.go
index 90e8903..ca317b2 100644
--- a/src/net/http/httputil/reverseproxy_test.go
+++ b/src/net/http/httputil/reverseproxy_test.go
@@ -784,7 +784,7 @@
rproxy.ErrorLog = log.New(io.Discard, "", 0) // quiet for tests
rproxy.ModifyResponse = func(resp *http.Response) error {
if resp.Header.Get("X-Hit-Mod") != "true" {
- return fmt.Errorf("tried to by-pass proxy")
+ return errors.New("tried to by-pass proxy")
}
return nil
}
diff --git a/src/net/http/internal/chunked_test.go b/src/net/http/internal/chunked_test.go
index 5e29a78..03681fb 100644
--- a/src/net/http/internal/chunked_test.go
+++ b/src/net/http/internal/chunked_test.go
@@ -7,6 +7,7 @@
import (
"bufio"
"bytes"
+ "errors"
"fmt"
"io"
"strings"
@@ -232,7 +233,7 @@
}

func TestChunkEndReadError(t *testing.T) {
- readErr := fmt.Errorf("chunk end read error")
+ readErr := errors.New("chunk end read error")

r := NewChunkedReader(io.MultiReader(strings.NewReader("4\r\nabcd"), iotest.ErrReader(readErr)))
if _, err := io.ReadAll(r); err != readErr {
diff --git a/src/net/http/request.go b/src/net/http/request.go
index dbe947a..0012f23 100644
--- a/src/net/http/request.go
+++ b/src/net/http/request.go
@@ -1084,7 +1084,7 @@
}
req.Header = Header(mimeHeader)
if len(req.Header["Host"]) > 1 {
- return nil, fmt.Errorf("too many Host headers")
+ return nil, errors.New("too many Host headers")
}

// RFC 7230, section 5.3: Must treat
diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go
index fb18cb2..dba7db0 100644
--- a/src/net/http/serve_test.go
+++ b/src/net/http/serve_test.go
@@ -860,7 +860,7 @@
if r.ProtoMajor != 2 {
return fmt.Errorf("http2 Get expected HTTP/2.0, got %q", r.Proto)
}
- return fmt.Errorf("http2 Get #2 expected error, got nil")
+ return errors.New("http2 Get #2 expected error, got nil")
}
expected := "stream ID 3; INTERNAL_ERROR" // client IDs are odd, second stream should be 3
if !strings.Contains(err.Error(), expected) {
diff --git a/src/net/sendfile_test.go b/src/net/sendfile_test.go
index 6edfb67..8e976fc 100644
--- a/src/net/sendfile_test.go
+++ b/src/net/sendfile_test.go
@@ -339,7 +339,7 @@
}

if err == nil {
- err = fmt.Errorf("expected ErrDeadlineExceeded, but got nil")
+ err = errors.New("expected ErrDeadlineExceeded, but got nil")
}
return err
}(ln)
diff --git a/src/net/textproto/reader.go b/src/net/textproto/reader.go
index 157c59b..aeb50d4 100644
--- a/src/net/textproto/reader.go
+++ b/src/net/textproto/reader.go
@@ -7,6 +7,7 @@
import (
"bufio"
"bytes"
+ "errors"
"fmt"
"io"
"strconv"
@@ -126,7 +127,7 @@
// error is returned from readContinuedLineSlice.
func (r *Reader) readContinuedLineSlice(validateFirstLine func([]byte) error) ([]byte, error) {
if validateFirstLine == nil {
- return nil, fmt.Errorf("missing validateFirstLine func")
+ return nil, errors.New("missing validateFirstLine func")
}

// Read the first line.
diff --git a/src/net/url/url.go b/src/net/url/url.go
index ecfd1d9..28ec72d 100644
--- a/src/net/url/url.go
+++ b/src/net/url/url.go
@@ -934,7 +934,7 @@
var key string
key, query, _ = strings.Cut(query, "&")
if strings.Contains(key, ";") {
- err = fmt.Errorf("invalid semicolon separator in query")
+ err = errors.New("invalid semicolon separator in query")
continue
}
if key == "" {
diff --git a/src/runtime/debug/mod.go b/src/runtime/debug/mod.go
index 688e258..719057a 100644
--- a/src/runtime/debug/mod.go
+++ b/src/runtime/debug/mod.go
@@ -5,6 +5,7 @@
package debug

import (
+ "errors"
"fmt"
"runtime"
"strconv"
@@ -189,7 +190,7 @@
return nil, fmt.Errorf("expected 3 columns for replacement; got %d", len(elem))
}
if last == nil {
- return nil, fmt.Errorf("replacement with no module on previous line")
+ return nil, errors.New("replacement with no module on previous line")
}
last.Replace = &Module{
Path: string(elem[0]),
@@ -200,21 +201,21 @@
case strings.HasPrefix(line, buildLine):
kv := line[len(buildLine):]
if len(kv) < 1 {
- return nil, fmt.Errorf("build line missing '='")
+ return nil, errors.New("build line missing '='")
}

var key, rawValue string
switch kv[0] {
case '=':
- return nil, fmt.Errorf("build line with missing key")
+ return nil, errors.New("build line with missing key")

case '`', '"':
rawKey, err := strconv.QuotedPrefix(kv)
if err != nil {
- return nil, fmt.Errorf("invalid quoted key in build line")
+ return nil, errors.New("invalid quoted key in build line")
}
if len(kv) == len(rawKey) {
- return nil, fmt.Errorf("build line missing '=' after quoted key")
+ return nil, errors.New("build line missing '=' after quoted key")
}
if c := kv[len(rawKey)]; c != '=' {
return nil, fmt.Errorf("unexpected character after quoted key: %q", c)
@@ -226,7 +227,7 @@
var ok bool
key, rawValue, ok = strings.Cut(kv, "=")
if !ok {
- return nil, fmt.Errorf("build line missing '=' after key")
+ return nil, errors.New("build line missing '=' after key")
}
if quoteKey(key) {
return nil, fmt.Errorf("unquoted key %q must be quoted", key)
@@ -240,7 +241,7 @@
var err error
value, err = strconv.Unquote(rawValue)
if err != nil {
- return nil, fmt.Errorf("invalid quoted value in build line")
+ return nil, errors.New("invalid quoted value in build line")
}

default:
diff --git a/src/runtime/malloc_test.go b/src/runtime/malloc_test.go
index 8ff8868..d130810 100644
--- a/src/runtime/malloc_test.go
+++ b/src/runtime/malloc_test.go
@@ -5,6 +5,7 @@
package runtime_test

import (
+ "errors"
"flag"
"fmt"
"internal/race"
@@ -37,7 +38,7 @@
if x != reflect.Zero(reflect.TypeOf(x)).Interface() {
return nil
}
- return fmt.Errorf("zero value")
+ return errors.New("zero value")
}
le := func(thresh float64) func(any) error {
return func(x any) error {
diff --git a/src/runtime/pprof/pprof.go b/src/runtime/pprof/pprof.go
index d75efce..566a242 100644
--- a/src/runtime/pprof/pprof.go
+++ b/src/runtime/pprof/pprof.go
@@ -75,6 +75,7 @@
import (
"bufio"
"bytes"
+ "errors"
"fmt"
"internal/abi"
"io"
@@ -778,7 +779,7 @@
}
// Double-check.
if cpu.profiling {
- return fmt.Errorf("cpu profiling already in use")
+ return errors.New("cpu profiling already in use")
}
cpu.profiling = true
runtime.SetCPUProfileRate(hz)
diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go
index ff4ecb4..579264f 100644
--- a/src/runtime/pprof/pprof_test.go
+++ b/src/runtime/pprof/pprof_test.go
@@ -9,6 +9,7 @@
import (
"bytes"
"context"
+ "errors"
"fmt"
"internal/abi"
"internal/profile"
@@ -156,7 +157,7 @@

compare := func(a, b time.Duration, maxDiff float64) error {
if a <= 0 || b <= 0 {
- return fmt.Errorf("Expected both time reports to be positive")
+ return errors.New("Expected both time reports to be positive")
}

if a < b {
diff --git a/src/runtime/pprof/proto.go b/src/runtime/pprof/proto.go
index 68dac42..baadd16 100644
--- a/src/runtime/pprof/proto.go
+++ b/src/runtime/pprof/proto.go
@@ -7,7 +7,7 @@
import (
"bytes"
"compress/gzip"
- "fmt"
+ "errors"
"internal/abi"
"io"
"os"
@@ -277,10 +277,10 @@
if !b.havePeriod {
// first record is period
if len(data) < 3 {
- return fmt.Errorf("truncated profile")
+ return errors.New("truncated profile")
}
if data[0] != 3 || data[2] == 0 {
- return fmt.Errorf("malformed profile")
+ return errors.New("malformed profile")
}
// data[2] is sampling rate in Hz. Convert to sampling
// period in nanoseconds.
@@ -309,13 +309,13 @@
// using the b.m profMap.
for len(data) > 0 {
if len(data) < 3 || data[0] > uint64(len(data)) {
- return fmt.Errorf("truncated profile")
+ return errors.New("truncated profile")
}
if data[0] < 3 || tags != nil && len(tags) < 1 {
- return fmt.Errorf("malformed profile")
+ return errors.New("malformed profile")
}
if len(tags) < 1 {
- return fmt.Errorf("mismatched profile records and tags")
+ return errors.New("mismatched profile records and tags")
}
count := data[2]
stk := data[3:data[0]]
@@ -337,7 +337,7 @@
}

if len(tags) != 0 {
- return fmt.Errorf("mismatched profile records and tags")
+ return errors.New("mismatched profile records and tags")
}
return nil
}
diff --git a/src/runtime/race/race_test.go b/src/runtime/race/race_test.go
index 4fe6168..9caea19 100644
--- a/src/runtime/race/race_test.go
+++ b/src/runtime/race/race_test.go
@@ -14,6 +14,7 @@
import (
"bufio"
"bytes"
+ "errors"
"fmt"
"internal/testenv"
"io"
@@ -179,7 +180,7 @@
out, _ := cmd.CombinedOutput()
if bytes.Contains(out, []byte("fatal error:")) {
// But don't expect runtime to crash.
- return out, fmt.Errorf("runtime fatal error")
+ return out, errors.New("runtime fatal error")
}
return out, nil
}
diff --git a/src/runtime/syscall_windows_test.go b/src/runtime/syscall_windows_test.go
index 034a1d8..571ebd6 100644
--- a/src/runtime/syscall_windows_test.go
+++ b/src/runtime/syscall_windows_test.go
@@ -953,7 +953,7 @@
// It returns new affinity mask.
func removeOneCPU(mask uintptr) (uintptr, error) {
if mask == 0 {
- return 0, fmt.Errorf("cpu affinity mask is empty")
+ return 0, errors.New("cpu affinity mask is empty")
}
maskbits := int(unsafe.Sizeof(mask) * 8)
for i := 0; i < maskbits; i++ {
diff --git a/src/runtime/testdata/testprog/numcpu_freebsd.go b/src/runtime/testdata/testprog/numcpu_freebsd.go
index 7209f67..33f6bef 100644
--- a/src/runtime/testdata/testprog/numcpu_freebsd.go
+++ b/src/runtime/testdata/testprog/numcpu_freebsd.go
@@ -112,7 +112,7 @@
func checkNCPU(list []string) error {
listString := strings.Join(list, ",")
if len(listString) == 0 {
- return fmt.Errorf("could not check against an empty CPU list")
+ return errors.New("could not check against an empty CPU list")
}

cListString := cpuSetRE.FindString(listString)
diff --git a/src/strings/replace_test.go b/src/strings/replace_test.go
index 34b5bad..7258ab6 100644
--- a/src/strings/replace_test.go
+++ b/src/strings/replace_test.go
@@ -6,6 +6,7 @@

import (
"bytes"
+ "errors"
"fmt"
. "strings"
"testing"
@@ -333,7 +334,7 @@
type errWriter struct{}

func (errWriter) Write(p []byte) (n int, err error) {
- return 0, fmt.Errorf("unwritable")
+ return 0, errors.New("unwritable")
}

// TestWriteStringError tests that WriteString returns an error
diff --git a/src/testing/benchmark.go b/src/testing/benchmark.go
index d8ec217..b198f94 100644
--- a/src/testing/benchmark.go
+++ b/src/testing/benchmark.go
@@ -5,6 +5,7 @@
package testing

import (
+ "errors"
"flag"
"fmt"
"internal/race"
@@ -52,14 +53,14 @@
if strings.HasSuffix(s, "x") {
n, err := strconv.ParseInt(s[:len(s)-1], 10, 0)
if err != nil || n < 0 || (!f.allowZero && n == 0) {
- return fmt.Errorf("invalid count")
+ return errors.New("invalid count")
}
*f = durationOrCountFlag{n: int(n)}
return nil
}
d, err := time.ParseDuration(s)
if err != nil || d < 0 || (!f.allowZero && d == 0) {
- return fmt.Errorf("invalid duration")
+ return errors.New("invalid duration")
}
*f = durationOrCountFlag{d: d}
return nil
diff --git a/src/text/template/funcs.go b/src/text/template/funcs.go
index dca5ed2..76343af 100644
--- a/src/text/template/funcs.go
+++ b/src/text/template/funcs.go
@@ -191,7 +191,7 @@
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
x = int64(index.Uint())
case reflect.Invalid:
- return 0, fmt.Errorf("cannot index slice/array with nil")
+ return 0, errors.New("cannot index slice/array with nil")
default:
return 0, fmt.Errorf("cannot index slice/array with type %s", index.Type())
}
@@ -209,13 +209,13 @@
func index(item reflect.Value, indexes ...reflect.Value) (reflect.Value, error) {
item = indirectInterface(item)
if !item.IsValid() {
- return reflect.Value{}, fmt.Errorf("index of untyped nil")
+ return reflect.Value{}, errors.New("index of untyped nil")
}
for _, index := range indexes {
index = indirectInterface(index)
var isNil bool
if item, isNil = indirect(item); isNil {
- return reflect.Value{}, fmt.Errorf("index of nil pointer")
+ return reflect.Value{}, errors.New("index of nil pointer")
}
switch item.Kind() {
case reflect.Array, reflect.Slice, reflect.String:
@@ -253,7 +253,7 @@
func slice(item reflect.Value, indexes ...reflect.Value) (reflect.Value, error) {
item = indirectInterface(item)
if !item.IsValid() {
- return reflect.Value{}, fmt.Errorf("slice of untyped nil")
+ return reflect.Value{}, errors.New("slice of untyped nil")
}
if len(indexes) > 3 {
return reflect.Value{}, fmt.Errorf("too many slice indexes: %d", len(indexes))
@@ -262,7 +262,7 @@
switch item.Kind() {
case reflect.String:
if len(indexes) == 3 {
- return reflect.Value{}, fmt.Errorf("cannot 3-index slice a string")
+ return reflect.Value{}, errors.New("cannot 3-index slice a string")
}
cap = item.Len()
case reflect.Array, reflect.Slice:
@@ -299,7 +299,7 @@
func length(item reflect.Value) (int, error) {
item, isNil := indirect(item)
if isNil {
- return 0, fmt.Errorf("len of nil pointer")
+ return 0, errors.New("len of nil pointer")
}
switch item.Kind() {
case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice, reflect.String:
@@ -315,7 +315,7 @@
func call(fn reflect.Value, args ...reflect.Value) (reflect.Value, error) {
fn = indirectInterface(fn)
if !fn.IsValid() {
- return reflect.Value{}, fmt.Errorf("call of nil")
+ return reflect.Value{}, errors.New("call of nil")
}
typ := fn.Type()
if typ.Kind() != reflect.Func {
diff --git a/src/text/template/helper.go b/src/text/template/helper.go
index 57905e6..2440de2 100644
--- a/src/text/template/helper.go
+++ b/src/text/template/helper.go
@@ -7,6 +7,7 @@
package template

import (
+ "errors"
"fmt"
"io/fs"
"os"
@@ -61,7 +62,7 @@
func parseFiles(t *Template, readFile func(string) (string, []byte, error), filenames ...string) (*Template, error) {
if len(filenames) == 0 {
// Not really a problem, but be consistent.
- return nil, fmt.Errorf("template: no files named in call to ParseFiles")
+ return nil, errors.New("template: no files named in call to ParseFiles")
}
for _, filename := range filenames {
name, b, err := readFile(filename)
diff --git a/src/time/zoneinfo_test.go b/src/time/zoneinfo_test.go
index 243ff8e..263edea 100644
--- a/src/time/zoneinfo_test.go
+++ b/src/time/zoneinfo_test.go
@@ -6,7 +6,6 @@

import (
"errors"
- "fmt"
"internal/testenv"
"os"
"reflect"
@@ -16,7 +15,7 @@

func init() {
if time.ZoneinfoForTesting() != nil {
- panic(fmt.Errorf("zoneinfo initialized before first LoadLocation"))
+ panic(errors.New("zoneinfo initialized before first LoadLocation"))
}
}

diff --git a/test/heapsampling.go b/test/heapsampling.go
index cc72832..e7d63c8 100644
--- a/test/heapsampling.go
+++ b/test/heapsampling.go
@@ -9,6 +9,7 @@
package main

import (
+ "errors"
"fmt"
"math"
"runtime"
@@ -197,7 +198,7 @@
// consistently far from the expected value.
func checkValue(fname string, ln int, testName string, want int64, got []int64) error {
if got == nil {
- return fmt.Errorf("Unexpected empty result")
+ return errors.New("Unexpected empty result")
}
min, max := got[0], got[0]
for _, g := range got[1:] {
diff --git a/test/run.go b/test/run.go
index 468379b..086350c 100644
--- a/test/run.go
+++ b/test/run.go
@@ -851,7 +851,7 @@
return
}
if err == errTimeout {
- t.err = fmt.Errorf("compilation timed out")
+ t.err = errors.New("compilation timed out")
return
}
} else {
@@ -1388,7 +1388,7 @@
}

if len(out) > 0 {
- errs = append(errs, fmt.Errorf("Unmatched Errors:"))
+ errs = append(errs, errors.New("Unmatched Errors:"))
for _, errLine := range out {
errs = append(errs, fmt.Errorf("%s", errLine))
}
diff --git a/test/typeparam/issue48185b.dir/main.go b/test/typeparam/issue48185b.dir/main.go
index ea157f7..f3d87d9 100644
--- a/test/typeparam/issue48185b.dir/main.go
+++ b/test/typeparam/issue48185b.dir/main.go
@@ -6,13 +6,13 @@

import (
"./a"
- "fmt"
+ "errors"
)

func main() {
_ = a.UnmarshalOptions1{
Unmarshalers: a.UnmarshalFuncV2(func(opts a.UnmarshalOptions1, dec *a.Decoder1, val *interface{}) (err error) {
- return fmt.Errorf("error")
+ return errors.New("error")
}),
}
}

To view, visit change 403938. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I660d15676d02b87aad82730f849ed866167d8c50
Gerrit-Change-Number: 403938
Gerrit-PatchSet: 1
Gerrit-Owner: Emmanuel Odeke <emma...@orijtech.com>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Rob Pike <r...@golang.org>
Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Rob Pike <r...@golang.org>
Gerrit-MessageType: newchange

Emmanuel Odeke (Gerrit)

unread,
May 4, 2022, 1:28:00 AM5/4/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Attention is currently required from: Ian Lance Taylor, Rob Pike.

Emmanuel Odeke uploaded patch set #2 to this change.

To view, visit change 403938. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I660d15676d02b87aad82730f849ed866167d8c50
Gerrit-Change-Number: 403938
Gerrit-PatchSet: 2
Gerrit-Owner: Emmanuel Odeke <emma...@orijtech.com>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Rob Pike <r...@golang.org>
Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
Gerrit-Attention: Rob Pike <r...@golang.org>
Gerrit-MessageType: newpatchset

Emmanuel Odeke (Gerrit)

unread,
May 4, 2022, 1:28:17 AM5/4/22
to goph...@pubsubhelper.golang.org, Ian Lance Taylor, Rob Pike, golang-co...@googlegroups.com

Attention is currently required from: Ian Lance Taylor, Rob Pike.

Patch set 2:Run-TryBot +1

View Change

    To view, visit change 403938. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I660d15676d02b87aad82730f849ed866167d8c50
    Gerrit-Change-Number: 403938
    Gerrit-PatchSet: 2
    Gerrit-Owner: Emmanuel Odeke <emma...@orijtech.com>
    Gerrit-Reviewer: Emmanuel Odeke <emma...@orijtech.com>
    Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Reviewer: Rob Pike <r...@golang.org>
    Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Attention: Rob Pike <r...@golang.org>
    Gerrit-Comment-Date: Wed, 04 May 2022 05:28:14 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Emmanuel Odeke (Gerrit)

    unread,
    May 4, 2022, 1:51:15 AM5/4/22
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Attention is currently required from: Emmanuel Odeke, Ian Lance Taylor, Rob Pike.

    Emmanuel Odeke uploaded patch set #3 to this change.

    View Change

    129 files changed, 395 insertions(+), 315 deletions(-)

    To view, visit change 403938. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I660d15676d02b87aad82730f849ed866167d8c50
    Gerrit-Change-Number: 403938
    Gerrit-PatchSet: 3
    Gerrit-Owner: Emmanuel Odeke <emma...@orijtech.com>
    Gerrit-Reviewer: Emmanuel Odeke <emma...@orijtech.com>
    Gerrit-Reviewer: Gopher Robot <go...@golang.org>
    Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Reviewer: Rob Pike <r...@golang.org>
    Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Attention: Rob Pike <r...@golang.org>
    Gerrit-Attention: Emmanuel Odeke <emma...@orijtech.com>
    Gerrit-MessageType: newpatchset

    Emmanuel Odeke (Gerrit)

    unread,
    May 4, 2022, 1:51:30 AM5/4/22
    to goph...@pubsubhelper.golang.org, Gopher Robot, Ian Lance Taylor, Rob Pike, golang-co...@googlegroups.com

    Attention is currently required from: Ian Lance Taylor, Rob Pike.

    Patch set 3:Run-TryBot +1

    View Change

      To view, visit change 403938. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I660d15676d02b87aad82730f849ed866167d8c50
      Gerrit-Change-Number: 403938
      Gerrit-PatchSet: 3
      Gerrit-Owner: Emmanuel Odeke <emma...@orijtech.com>
      Gerrit-Reviewer: Emmanuel Odeke <emma...@orijtech.com>
      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
      Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Reviewer: Rob Pike <r...@golang.org>
      Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Attention: Rob Pike <r...@golang.org>
      Gerrit-Comment-Date: Wed, 04 May 2022 05:51:25 +0000

      Emmanuel Odeke (Gerrit)

      unread,
      May 4, 2022, 2:16:09 AM5/4/22
      to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

      Attention is currently required from: Emmanuel Odeke, Ian Lance Taylor, Rob Pike.

      Emmanuel Odeke uploaded patch set #4 to this change.

      View Change

      129 files changed, 396 insertions(+), 315 deletions(-)

      To view, visit change 403938. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I660d15676d02b87aad82730f849ed866167d8c50
      Gerrit-Change-Number: 403938
      Gerrit-PatchSet: 4
      Gerrit-Owner: Emmanuel Odeke <emma...@orijtech.com>
      Gerrit-Reviewer: Emmanuel Odeke <emma...@orijtech.com>
      Gerrit-Reviewer: Gopher Robot <go...@golang.org>
      Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Reviewer: Rob Pike <r...@golang.org>
      Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Attention: Rob Pike <r...@golang.org>

      Emmanuel Odeke (Gerrit)

      unread,
      May 4, 2022, 2:16:50 AM5/4/22
      to goph...@pubsubhelper.golang.org, Gopher Robot, Ian Lance Taylor, Rob Pike, golang-co...@googlegroups.com

      Attention is currently required from: Ian Lance Taylor, Rob Pike.

      Patch set 4:Run-TryBot +1

      View Change

        To view, visit change 403938. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I660d15676d02b87aad82730f849ed866167d8c50
        Gerrit-Change-Number: 403938
        Gerrit-PatchSet: 4
        Gerrit-Owner: Emmanuel Odeke <emma...@orijtech.com>
        Gerrit-Reviewer: Emmanuel Odeke <emma...@orijtech.com>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
        Gerrit-Reviewer: Rob Pike <r...@golang.org>
        Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
        Gerrit-Attention: Rob Pike <r...@golang.org>
        Gerrit-Comment-Date: Wed, 04 May 2022 06:16:47 +0000

        Emmanuel Odeke (Gerrit)

        unread,
        Apr 1, 2024, 9:23:20 AM4/1/24
        to goph...@pubsubhelper.golang.org, Russ Cox, Gopher Robot, Ian Lance Taylor, golang-co...@googlegroups.com

        Emmanuel Odeke abandoned this change

        Related details

        Attention set is empty
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement satisfiedLegacy-TryBots-Pass
        • requirement is not satisfiedNo-Holds
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: abandon
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I660d15676d02b87aad82730f849ed866167d8c50
        Gerrit-Change-Number: 403938
        Gerrit-PatchSet: 4
        Gerrit-Owner: Emmanuel Odeke <emma...@orijtech.com>
        Gerrit-Reviewer: Emmanuel Odeke <emma...@orijtech.com>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
        Gerrit-Reviewer: Russ Cox <r...@golang.org>
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy
        Reply all
        Reply to author
        Forward
        0 new messages