]> Cypherpunks.ru repositories - gostls13.git/commitdiff
all: use strings.ReplaceAll and bytes.ReplaceAll where applicable
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 26 Sep 2018 21:10:21 +0000 (21:10 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 26 Sep 2018 22:14:25 +0000 (22:14 +0000)
I omitted vendor directories and anything necessary for bootstrapping.
(Tested by bootstrapping with Go 1.4)

Updates #27864

Change-Id: I7d9b68d0372d3a34dee22966cca323513ece7e8a
Reviewed-on: https://go-review.googlesource.com/137856
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
56 files changed:
src/cmd/fix/main.go
src/cmd/fix/typecheck.go
src/cmd/go/go_test.go
src/cmd/go/internal/envcmd/env.go
src/cmd/go/internal/get/vcs.go
src/cmd/go/internal/modconv/convert_test.go
src/cmd/go/internal/modfetch/codehost/codehost.go
src/cmd/go/internal/modfetch/coderepo_test.go
src/cmd/go/internal/modfetch/proxy.go
src/cmd/go/internal/modload/import_test.go
src/cmd/go/internal/modload/query_test.go
src/cmd/go/internal/search/search.go
src/cmd/go/internal/work/build.go
src/cmd/go/internal/work/exec.go
src/cmd/go/proxy_test.go
src/cmd/go/script_test.go
src/cmd/go/testdata/addmod.go
src/cmd/go/vendor_test.go
src/cmd/gofmt/gofmt_test.go
src/cmd/internal/goobj/read.go
src/cmd/trace/trace.go
src/cmd/vet/main.go
src/cmd/vet/vet_test.go
src/crypto/rsa/pss_test.go
src/crypto/x509/root_darwin_arm_gen.go
src/encoding/base32/base32_test.go
src/encoding/base64/base64_test.go
src/flag/flag.go
src/go/constant/value_test.go
src/go/doc/doc_test.go
src/go/printer/example_test.go
src/html/template/js.go
src/html/template/url.go
src/mime/multipart/formdata_test.go
src/mime/multipart/multipart_test.go
src/net/http/cgi/child.go
src/net/http/httputil/dump_test.go
src/net/http/readrequest_test.go
src/net/http/request_test.go
src/net/http/serve_test.go
src/net/lookup_windows_test.go
src/net/mail/message_test.go
src/net/net_windows_test.go
src/net/url/example_test.go
src/net/url/url_test.go
src/os/path_windows_test.go
src/path/filepath/path.go
src/path/filepath/path_test.go
src/path/filepath/path_windows.go
src/path/filepath/path_windows_test.go
src/runtime/pprof/internal/profile/profile.go
src/runtime/pprof/pprof_test.go
src/runtime/runtime-gdb_test.go
src/strings/example_test.go
src/testing/sub_test.go
src/text/template/exec.go

index f06abae171b0ea37ace45746e9aa8e0a10ed884f..f54a5e0d963bf76b14efaf97026ce31d05883733 100644 (file)
@@ -52,7 +52,7 @@ func usage() {
                        fmt.Fprintf(os.Stderr, "\n%s\n", f.name)
                }
                desc := strings.TrimSpace(f.desc)
-               desc = strings.Replace(desc, "\n", "\n\t", -1)
+               desc = strings.ReplaceAll(desc, "\n", "\n\t")
                fmt.Fprintf(os.Stderr, "\t%s\n", desc)
        }
        os.Exit(2)
index eafb626c74768133293d2eef82d91f11f129cc93..66e0cdcec056dfccf0d376c657345ed6626010be 100644 (file)
@@ -193,12 +193,12 @@ func typecheck(cfg *TypeConfig, f *ast.File) (typeof map[interface{}]string, ass
                                        var params, results []string
                                        for _, p := range fn.Type.Params.List {
                                                t := gofmt(p.Type)
-                                               t = strings.Replace(t, "_Ctype_", "C.", -1)
+                                               t = strings.ReplaceAll(t, "_Ctype_", "C.")
                                                params = append(params, t)
                                        }
                                        for _, r := range fn.Type.Results.List {
                                                t := gofmt(r.Type)
-                                               t = strings.Replace(t, "_Ctype_", "C.", -1)
+                                               t = strings.ReplaceAll(t, "_Ctype_", "C.")
                                                results = append(results, t)
                                        }
                                        cfg.External["C."+fn.Name.Name[7:]] = joinFunc(params, results)
index 962b52fd3de55c1478e2f97264fd7faf204ee32e..139ee73ae097fc332828f435478c7b56dc788ee9 100644 (file)
@@ -1090,7 +1090,7 @@ func testMove(t *testing.T, vcs, url, base, config string) {
                path := tg.path(filepath.Join("src", config))
                data, err := ioutil.ReadFile(path)
                tg.must(err)
-               data = bytes.Replace(data, []byte(base), []byte(base+"XXX"), -1)
+               data = bytes.ReplaceAll(data, []byte(base), []byte(base+"XXX"))
                tg.must(ioutil.WriteFile(path, data, 0644))
        }
        if vcs == "git" {
@@ -2360,14 +2360,14 @@ func TestShadowingLogic(t *testing.T) {
 
        // The math in root1 is not "math" because the standard math is.
        tg.run("list", "-f", "({{.ImportPath}}) ({{.ConflictDir}})", "./testdata/shadow/root1/src/math")
-       pwdForwardSlash := strings.Replace(pwd, string(os.PathSeparator), "/", -1)
+       pwdForwardSlash := strings.ReplaceAll(pwd, string(os.PathSeparator), "/")
        if !strings.HasPrefix(pwdForwardSlash, "/") {
                pwdForwardSlash = "/" + pwdForwardSlash
        }
        // The output will have makeImportValid applies, but we only
        // bother to deal with characters we might reasonably see.
        for _, r := range " :" {
-               pwdForwardSlash = strings.Replace(pwdForwardSlash, string(r), "_", -1)
+               pwdForwardSlash = strings.ReplaceAll(pwdForwardSlash, string(r), "_")
        }
        want := "(_" + pwdForwardSlash + "/testdata/shadow/root1/src/math) (" + filepath.Join(runtime.GOROOT(), "src", "math") + ")"
        if strings.TrimSpace(tg.getStdout()) != want {
@@ -2557,7 +2557,7 @@ func TestCoverageErrorLine(t *testing.T) {
 
        // It's OK that stderr2 drops the character position in the error,
        // because of the //line directive (see golang.org/issue/22662).
-       stderr = strings.Replace(stderr, "p.go:4:2:", "p.go:4:", -1)
+       stderr = strings.ReplaceAll(stderr, "p.go:4:2:", "p.go:4:")
        if stderr != stderr2 {
                t.Logf("test -cover changed error messages:\nbefore:\n%s\n\nafter:\n%s", stderr, stderr2)
                t.Skip("golang.org/issue/22660")
@@ -6171,7 +6171,7 @@ func TestCDAndGOPATHAreDifferent(t *testing.T) {
 
        testCDAndGOPATHAreDifferent(tg, cd, gopath)
        if runtime.GOOS == "windows" {
-               testCDAndGOPATHAreDifferent(tg, cd, strings.Replace(gopath, `\`, `/`, -1))
+               testCDAndGOPATHAreDifferent(tg, cd, strings.ReplaceAll(gopath, `\`, `/`))
                testCDAndGOPATHAreDifferent(tg, cd, strings.ToUpper(gopath))
                testCDAndGOPATHAreDifferent(tg, cd, strings.ToLower(gopath))
        }
index afadbade38ef789ff2a573e81f94998566083898..85a42e0519ad6917ce7827e32916ef5c116a5c22 100644 (file)
@@ -203,7 +203,7 @@ func runEnv(cmd *base.Command, args []string) {
                                fmt.Printf("%s=\"%s\"\n", e.Name, e.Value)
                        case "plan9":
                                if strings.IndexByte(e.Value, '\x00') < 0 {
-                                       fmt.Printf("%s='%s'\n", e.Name, strings.Replace(e.Value, "'", "''", -1))
+                                       fmt.Printf("%s='%s'\n", e.Name, strings.ReplaceAll(e.Value, "'", "''"))
                                } else {
                                        v := strings.Split(e.Value, "\x00")
                                        fmt.Printf("%s=(", e.Name)
index 0f7b623ec31e88fea5b0113943b017ae5639e4d9..173934b84ec96d4f435953f9d0fa88d9e3ab74cf 100644 (file)
@@ -964,7 +964,7 @@ func matchGoImport(imports []metaImport, importPath string) (metaImport, error)
 // expand rewrites s to replace {k} with match[k] for each key k in match.
 func expand(match map[string]string, s string) string {
        for k, v := range match {
-               s = strings.Replace(s, "{"+k+"}", v, -1)
+               s = strings.ReplaceAll(s, "{"+k+"}", v)
        }
        return s
 }
index ad27abb8ef7e1831aa2f6933d830e8865d9393a6..4d55d73f21423646a8f0f57d0d84389348d4eaa6 100644 (file)
@@ -146,7 +146,7 @@ func TestConvertLegacyConfig(t *testing.T) {
        }
 
        for _, tt := range tests {
-               t.Run(strings.Replace(tt.path, "/", "_", -1)+"_"+tt.vers, func(t *testing.T) {
+               t.Run(strings.ReplaceAll(tt.path, "/", "_")+"_"+tt.vers, func(t *testing.T) {
                        f, err := modfile.Parse("golden", []byte(tt.gomod), nil)
                        if err != nil {
                                t.Fatal(err)
index 4103ddc717f4912005cf9374519ccb85b6ead5c3..4205cd26bda11d4e4ae8e9bc209c0b016bacc00e 100644 (file)
@@ -185,7 +185,7 @@ func (e *RunError) Error() string {
        text := e.Cmd + ": " + e.Err.Error()
        stderr := bytes.TrimRight(e.Stderr, "\n")
        if len(stderr) > 0 {
-               text += ":\n\t" + strings.Replace(string(stderr), "\n", "\n\t", -1)
+               text += ":\n\t" + strings.ReplaceAll(string(stderr), "\n", "\n\t")
        }
        return text
 }
index 79b82786cb96548ba1bb93bd4dd04598d2ac2daf..0b62b9ee76bd5e918782bf05b06ac7e06d09b74d 100644 (file)
@@ -423,7 +423,7 @@ func TestCodeRepo(t *testing.T) {
                                }
                        }
                }
-               t.Run(strings.Replace(tt.path, "/", "_", -1)+"/"+tt.rev, f)
+               t.Run(strings.ReplaceAll(tt.path, "/", "_")+"/"+tt.rev, f)
                if strings.HasPrefix(tt.path, vgotest1git) {
                        for _, alt := range altVgotests {
                                // Note: Communicating with f through tt; should be cleaned up.
@@ -442,7 +442,7 @@ func TestCodeRepo(t *testing.T) {
                                tt.rev = remap(tt.rev, m)
                                tt.gomoderr = remap(tt.gomoderr, m)
                                tt.ziperr = remap(tt.ziperr, m)
-                               t.Run(strings.Replace(tt.path, "/", "_", -1)+"/"+tt.rev, f)
+                               t.Run(strings.ReplaceAll(tt.path, "/", "_")+"/"+tt.rev, f)
                                tt = old
                        }
                }
@@ -473,9 +473,9 @@ func remap(name string, m map[string]string) string {
                }
        }
        for k, v := range m {
-               name = strings.Replace(name, k, v, -1)
+               name = strings.ReplaceAll(name, k, v)
                if codehost.AllHex(k) {
-                       name = strings.Replace(name, k[:12], v[:12], -1)
+                       name = strings.ReplaceAll(name, k[:12], v[:12])
                }
        }
        return name
@@ -522,7 +522,7 @@ func TestCodeRepoVersions(t *testing.T) {
        }
        defer os.RemoveAll(tmpdir)
        for _, tt := range codeRepoVersionsTests {
-               t.Run(strings.Replace(tt.path, "/", "_", -1), func(t *testing.T) {
+               t.Run(strings.ReplaceAll(tt.path, "/", "_"), func(t *testing.T) {
                        repo, err := Lookup(tt.path)
                        if err != nil {
                                t.Fatalf("Lookup(%q): %v", tt.path, err)
@@ -570,7 +570,7 @@ func TestLatest(t *testing.T) {
        }
        defer os.RemoveAll(tmpdir)
        for _, tt := range latestTests {
-               name := strings.Replace(tt.path, "/", "_", -1)
+               name := strings.ReplaceAll(tt.path, "/", "_")
                t.Run(name, func(t *testing.T) {
                        repo, err := Lookup(tt.path)
                        if err != nil {
index 5f856b80d2e16a1b2d69145856736fb93b82b4cc..7c78502f318d7d490e78f79a2dc0db174a342932 100644 (file)
@@ -248,5 +248,5 @@ func (p *proxyRepo) Zip(version string, tmpdir string) (tmpfile string, err erro
 // That is, it escapes things like ? and # (which really shouldn't appear anyway).
 // It does not escape / to %2F: our REST API is designed so that / can be left as is.
 func pathEscape(s string) string {
-       return strings.Replace(url.PathEscape(s), "%2F", "/", -1)
+       return strings.ReplaceAll(url.PathEscape(s), "%2F", "/")
 }
index 3f4ddab436cc49a79dc74c852d2b3acd66e4fc79..9422a3d960c16278fad5df23576a4f6a2603cd5b 100644 (file)
@@ -45,7 +45,7 @@ func TestImport(t *testing.T) {
        testenv.MustHaveExternalNetwork(t)
 
        for _, tt := range importTests {
-               t.Run(strings.Replace(tt.path, "/", "_", -1), func(t *testing.T) {
+               t.Run(strings.ReplaceAll(tt.path, "/", "_"), func(t *testing.T) {
                        // Note that there is no build list, so Import should always fail.
                        m, dir, err := Import(tt.path)
                        if err == nil {
index 7f3ffabef742035cf03634bf58d452c1d5420df0..9b07383217175cafb4eee83c7db5b4cec2b22faf 100644 (file)
@@ -132,7 +132,7 @@ func TestQuery(t *testing.T) {
                        ok, _ := path.Match(allow, m.Version)
                        return ok
                }
-               t.Run(strings.Replace(tt.path, "/", "_", -1)+"/"+tt.query+"/"+allow, func(t *testing.T) {
+               t.Run(strings.ReplaceAll(tt.path, "/", "_")+"/"+tt.query+"/"+allow, func(t *testing.T) {
                        info, err := Query(tt.path, tt.query, allowed)
                        if tt.err != "" {
                                if err != nil && err.Error() == tt.err {
index 60ae73696bb4c1baf24ccce8c7b44d35b2c0fa5e..0ca60e73497e2188a424dbb0fcbdfe8a0bb325ca 100644 (file)
@@ -275,7 +275,7 @@ func MatchPattern(pattern string) func(name string) bool {
        case strings.HasSuffix(re, `/\.\.\.`):
                re = strings.TrimSuffix(re, `/\.\.\.`) + `(/\.\.\.)?`
        }
-       re = strings.Replace(re, `\.\.\.`, `[^`+vendorChar+`]*`, -1)
+       re = strings.ReplaceAll(re, `\.\.\.`, `[^`+vendorChar+`]*`)
 
        reg := regexp.MustCompile(`^` + re + `$`)
 
@@ -353,7 +353,7 @@ func CleanPatterns(patterns []string) []string {
                // as a courtesy to Windows developers, rewrite \ to /
                // in command-line arguments. Handles .\... and so on.
                if filepath.Separator == '\\' {
-                       a = strings.Replace(a, `\`, `/`, -1)
+                       a = strings.ReplaceAll(a, `\`, `/`)
                }
 
                // Put argument in canonical form, but preserve leading ./.
index dd482b677d5749630c9388eebe4e512759c275e7..145b87513a9166aecb9d9c7b7efd690425f3b1b3 100644 (file)
@@ -398,10 +398,10 @@ func libname(args []string, pkgs []*load.Package) (string, error) {
                                        arg = bp.ImportPath
                                }
                        }
-                       appendName(strings.Replace(arg, "/", "-", -1))
+                       appendName(strings.ReplaceAll(arg, "/", "-"))
                } else {
                        for _, pkg := range pkgs {
-                               appendName(strings.Replace(pkg.ImportPath, "/", "-", -1))
+                               appendName(strings.ReplaceAll(pkg.ImportPath, "/", "-"))
                        }
                }
        } else if haveNonMeta { // have both meta package and a non-meta one
index 01414a3d5775b25c307a5856d1c9f4d697d0428d..158f5f3b173dbdc6c270ff4bb4c0a8b445f06482 100644 (file)
@@ -1705,14 +1705,14 @@ func (b *Builder) fmtcmd(dir string, format string, args ...interface{}) string
                if dir[len(dir)-1] == filepath.Separator {
                        dot += string(filepath.Separator)
                }
-               cmd = strings.Replace(" "+cmd, " "+dir, dot, -1)[1:]
+               cmd = strings.ReplaceAll(" "+cmd, " "+dir, dot)[1:]
                if b.scriptDir != dir {
                        b.scriptDir = dir
                        cmd = "cd " + dir + "\n" + cmd
                }
        }
        if b.WorkDir != "" {
-               cmd = strings.Replace(cmd, b.WorkDir, "$WORK", -1)
+               cmd = strings.ReplaceAll(cmd, b.WorkDir, "$WORK")
        }
        return cmd
 }
@@ -1754,10 +1754,10 @@ func (b *Builder) showOutput(a *Action, dir, desc, out string) {
        prefix := "# " + desc
        suffix := "\n" + out
        if reldir := base.ShortPath(dir); reldir != dir {
-               suffix = strings.Replace(suffix, " "+dir, " "+reldir, -1)
-               suffix = strings.Replace(suffix, "\n"+dir, "\n"+reldir, -1)
+               suffix = strings.ReplaceAll(suffix, " "+dir, " "+reldir)
+               suffix = strings.ReplaceAll(suffix, "\n"+dir, "\n"+reldir)
        }
-       suffix = strings.Replace(suffix, " "+b.WorkDir, " $WORK", -1)
+       suffix = strings.ReplaceAll(suffix, " "+b.WorkDir, " $WORK")
 
        if a != nil && a.output != nil {
                a.output = append(a.output, prefix...)
index 212e5aa08f7a10c0fb43993328d7a17e93ef5ff1..97fc4b0e80735c2b45f78fd505d1db929eb66bd3 100644 (file)
@@ -78,7 +78,7 @@ func readModList() {
                if i < 0 {
                        continue
                }
-               encPath := strings.Replace(name[:i], "_", "/", -1)
+               encPath := strings.ReplaceAll(name[:i], "_", "/")
                path, err := module.DecodePath(encPath)
                if err != nil {
                        fmt.Fprintf(os.Stderr, "go proxy_test: %v\n", err)
@@ -256,7 +256,7 @@ func readArchive(path, vers string) *txtar.Archive {
                return nil
        }
 
-       prefix := strings.Replace(enc, "/", "_", -1)
+       prefix := strings.ReplaceAll(enc, "/", "_")
        name := filepath.Join(cmdGoDir, "testdata/mod", prefix+"_"+encVers+".txt")
        a := archiveCache.Do(name, func() interface{} {
                a, err := txtar.ParseFile(name)
index 7c083a87b932f392d45da66dd999cbaead537f27..31c6ede2a59a3e48007fbe9482c30489ddb92d99 100644 (file)
@@ -329,7 +329,7 @@ func (ts *testScript) cmdAddcrlf(neg bool, args []string) {
                file = ts.mkabs(file)
                data, err := ioutil.ReadFile(file)
                ts.check(err)
-               ts.check(ioutil.WriteFile(file, bytes.Replace(data, []byte("\n"), []byte("\r\n"), -1), 0666))
+               ts.check(ioutil.WriteFile(file, bytes.ReplaceAll(data, []byte("\n"), []byte("\r\n")), 0666))
        }
 }
 
@@ -630,7 +630,7 @@ func scriptMatch(ts *testScript, neg bool, args []string, text, name string) {
        }
 
        // Matching against workdir would be misleading.
-       text = strings.Replace(text, ts.workdir, "$WORK", -1)
+       text = strings.ReplaceAll(text, ts.workdir, "$WORK")
 
        if neg {
                if re.MatchString(text) {
@@ -691,7 +691,7 @@ func (ts *testScript) cmdSymlink(neg bool, args []string) {
 
 // abbrev abbreviates the actual work directory in the string s to the literal string "$WORK".
 func (ts *testScript) abbrev(s string) string {
-       s = strings.Replace(s, ts.workdir, "$WORK", -1)
+       s = strings.ReplaceAll(s, ts.workdir, "$WORK")
        if *testWork {
                // Expose actual $WORK value in environment dump on first line of work script,
                // so that the user can find out what directory -testwork left behind.
@@ -885,17 +885,17 @@ var diffTests = []struct {
 func TestDiff(t *testing.T) {
        for _, tt := range diffTests {
                // Turn spaces into \n.
-               text1 := strings.Replace(tt.text1, " ", "\n", -1)
+               text1 := strings.ReplaceAll(tt.text1, " ", "\n")
                if text1 != "" {
                        text1 += "\n"
                }
-               text2 := strings.Replace(tt.text2, " ", "\n", -1)
+               text2 := strings.ReplaceAll(tt.text2, " ", "\n")
                if text2 != "" {
                        text2 += "\n"
                }
                out := diff(text1, text2)
                // Cut final \n, cut spaces, turn remaining \n into spaces.
-               out = strings.Replace(strings.Replace(strings.TrimSuffix(out, "\n"), " ", "", -1), "\n", " ", -1)
+               out = strings.ReplaceAll(strings.ReplaceAll(strings.TrimSuffix(out, "\n"), " ", ""), "\n", " ")
                if out != tt.diff {
                        t.Errorf("diff(%q, %q) = %q, want %q", text1, text2, out, tt.diff)
                }
index 19850af0f37b29b22186c80a25d9bce6f7f696d1..8bb6056a540ae24850eb74f557fd56c5ac2ffdac 100644 (file)
@@ -142,7 +142,7 @@ func main() {
                }
 
                data := txtar.Format(a)
-               target := filepath.Join("mod", strings.Replace(path, "/", "_", -1)+"_"+vers+".txt")
+               target := filepath.Join("mod", strings.ReplaceAll(path, "/", "_")+"_"+vers+".txt")
                if err := ioutil.WriteFile(target, data, 0666); err != nil {
                        log.Printf("%s: %v", arg, err)
                        exitCode = 1
index 22aa643b0032e11cade39740ccf0ab07f592e683..c302d7e9b584146f1df0261a7b8ebceb6dd265ac 100644 (file)
@@ -37,7 +37,7 @@ func TestVendorImports(t *testing.T) {
                vend/x/vendor/p/p [notfound]
                vend/x/vendor/r []
        `
-       want = strings.Replace(want+"\t", "\n\t\t", "\n", -1)
+       want = strings.ReplaceAll(want+"\t", "\n\t\t", "\n")
        want = strings.TrimPrefix(want, "\n")
 
        have := tg.stdout.String()
index 16b653b6460d7892126307eef1943282d8fbf51e..3008365cd237ca4ac4513a370b51dd326292ad0c 100644 (file)
@@ -200,7 +200,7 @@ func TestDiff(t *testing.T) {
        }
 
        if runtime.GOOS == "windows" {
-               b = bytes.Replace(b, []byte{'\r', '\n'}, []byte{'\n'}, -1)
+               b = bytes.ReplaceAll(b, []byte{'\r', '\n'}, []byte{'\n'})
        }
 
        bs := bytes.SplitN(b, []byte{'\n'}, 3)
index e39180cad666c5c5473209f0a1168ffca0d0f3f4..2d618eefa557a1c9951b559ce3cd0edc00d5cbab 100644 (file)
@@ -293,7 +293,7 @@ func (r *objReader) readRef() {
        // In a symbol name in an object file, "". denotes the
        // prefix for the package in which the object file has been found.
        // Expand it.
-       name = strings.Replace(name, `"".`, r.pkgprefix, -1)
+       name = strings.ReplaceAll(name, `"".`, r.pkgprefix)
 
        // An individual object file only records version 0 (extern) or 1 (static).
        // To make static symbols unique across all files being read, we
index 676b9ffa5ab6bc12f644588a7b0241c7dbb73985..07fc4333eba2e70b85eec200d422e09f544cbff1 100644 (file)
@@ -38,7 +38,7 @@ func httpTrace(w http.ResponseWriter, r *http.Request) {
                http.Error(w, err.Error(), http.StatusInternalServerError)
                return
        }
-       html := strings.Replace(templTrace, "{{PARAMS}}", r.Form.Encode(), -1)
+       html := strings.ReplaceAll(templTrace, "{{PARAMS}}", r.Form.Encode())
        w.Write([]byte(html))
 
 }
index 646adf4d76d5facd2c660f63f87d4dd5f23dc643..6e885121c8cd581f1850c852725f557d230d193a 100644 (file)
@@ -273,7 +273,7 @@ func main() {
        // Accept space-separated tags because that matches
        // the go command's other subcommands.
        // Accept commas because go tool vet traditionally has.
-       tagList = strings.Fields(strings.Replace(*tags, ",", " ", -1))
+       tagList = strings.Fields(strings.ReplaceAll(*tags, ",", " "))
 
        initPrintFlags()
        initUnusedFlags()
index 90665d77bc655e17536deea88e8dd3e43c2fd5de..df84d6cc98378ffd479954d1c7aa9fbfdf261fe3 100644 (file)
@@ -243,7 +243,7 @@ func errorCheck(outStr string, wantAuto bool, fullshort ...string) (err error) {
        for i := range out {
                for j := 0; j < len(fullshort); j += 2 {
                        full, short := fullshort[j], fullshort[j+1]
-                       out[i] = strings.Replace(out[i], full, short, -1)
+                       out[i] = strings.ReplaceAll(out[i], full, short)
                }
        }
 
index cae24e58c6794ce5db502932f6504934bf4115cc..dfa8d8bb5ad02e6feb3420348680c146b03740ad 100644 (file)
@@ -103,7 +103,7 @@ func TestPSSGolden(t *testing.T) {
                        switch {
                        case len(line) == 0:
                                if len(partialValue) > 0 {
-                                       values <- strings.Replace(partialValue, " ", "", -1)
+                                       values <- strings.ReplaceAll(partialValue, " ", "")
                                        partialValue = ""
                                        lastWasValue = true
                                }
index b5580d6f02a3b97375e232bd7f5c3e55e8ab60af..bc44124a78556d097b9cc20eee6f4b980947d1ca 100644 (file)
@@ -154,9 +154,9 @@ func fetchCertIDs() ([]certID, error) {
                values := regexp.MustCompile("(?s)<td>(.*?)</td>").FindAllStringSubmatch(row, -1)
                name := values[cols["Certificate name"]][1]
                fingerprint := values[cols["Fingerprint (SHA-256)"]][1]
-               fingerprint = strings.Replace(fingerprint, "<br>", "", -1)
-               fingerprint = strings.Replace(fingerprint, "\n", "", -1)
-               fingerprint = strings.Replace(fingerprint, " ", "", -1)
+               fingerprint = strings.ReplaceAll(fingerprint, "<br>", "")
+               fingerprint = strings.ReplaceAll(fingerprint, "\n", "")
+               fingerprint = strings.ReplaceAll(fingerprint, " ", "")
                fingerprint = strings.ToLower(fingerprint)
 
                ids = append(ids, certID{
index c5506ed4de70d40ae463a85a66f8866ef54e2fa0..b74054ba4022764fb5ebc64f414b74917709ee3b 100644 (file)
@@ -425,7 +425,7 @@ IZJAOZSWY2LUEBSXG43FEBRWS3DMOVWSAZDPNRXXEZJAMV2SAZTVM5UWC5BANZ2WY3DBBJYGC4TJMF
 NZ2CYIDTOVXHIIDJNYFGG5LMOBQSA4LVNEQG6ZTGNFRWSYJAMRSXGZLSOVXHIIDNN5WGY2LUEBQW42
 LNEBUWIIDFON2CA3DBMJXXE5LNFY==
 ====`
-       encodedShort := strings.Replace(encoded, "\n", "", -1)
+       encodedShort := strings.ReplaceAll(encoded, "\n", "")
 
        dec := NewDecoder(StdEncoding, strings.NewReader(encoded))
        res1, err := ioutil.ReadAll(dec)
@@ -465,7 +465,7 @@ func TestWithCustomPadding(t *testing.T) {
        for _, testcase := range pairs {
                defaultPadding := StdEncoding.EncodeToString([]byte(testcase.decoded))
                customPadding := StdEncoding.WithPadding('@').EncodeToString([]byte(testcase.decoded))
-               expected := strings.Replace(defaultPadding, "=", "@", -1)
+               expected := strings.ReplaceAll(defaultPadding, "=", "@")
 
                if expected != customPadding {
                        t.Errorf("Expected custom %s, got %s", expected, customPadding)
@@ -675,7 +675,7 @@ func TestWithoutPaddingClose(t *testing.T) {
 
                        expected := testpair.encoded
                        if encoding.padChar == NoPadding {
-                               expected = strings.Replace(expected, "=", "", -1)
+                               expected = strings.ReplaceAll(expected, "=", "")
                        }
 
                        res := buf.String()
@@ -697,7 +697,7 @@ func TestDecodeReadAll(t *testing.T) {
                for encIndex, encoding := range encodings {
                        encoded := pair.encoded
                        if encoding.padChar == NoPadding {
-                               encoded = strings.Replace(encoded, "=", "", -1)
+                               encoded = strings.ReplaceAll(encoded, "=", "")
                        }
 
                        decReader, err := ioutil.ReadAll(NewDecoder(encoding, strings.NewReader(encoded)))
@@ -723,7 +723,7 @@ func TestDecodeSmallBuffer(t *testing.T) {
                        for encIndex, encoding := range encodings {
                                encoded := pair.encoded
                                if encoding.padChar == NoPadding {
-                                       encoded = strings.Replace(encoded, "=", "", -1)
+                                       encoded = strings.ReplaceAll(encoded, "=", "")
                                }
 
                                decoder := NewDecoder(encoding, strings.NewReader(encoded))
index f019654f5b57edaccb5c2a0f6ac69b775241ced6..f7f312ca39324cafd44931bfbd2c5f7f15f56357 100644 (file)
@@ -53,8 +53,8 @@ func stdRef(ref string) string {
 
 // Convert a reference string to URL-encoding
 func urlRef(ref string) string {
-       ref = strings.Replace(ref, "+", "-", -1)
-       ref = strings.Replace(ref, "/", "_", -1)
+       ref = strings.ReplaceAll(ref, "+", "-")
+       ref = strings.ReplaceAll(ref, "/", "_")
        return ref
 }
 
@@ -72,7 +72,7 @@ func rawURLRef(ref string) string {
 var funnyEncoding = NewEncoding(encodeStd).WithPadding(rune('@'))
 
 func funnyRef(ref string) string {
-       return strings.Replace(ref, "=", "@", -1)
+       return strings.ReplaceAll(ref, "=", "@")
 }
 
 type encodingTest struct {
@@ -418,7 +418,7 @@ j+mSARB/17pKVXYWHXjsj7yIex0PadzXMO1zT5KHoNA3HT8ietoGhgjsfA+CSnvvqh/jJtqsrwOv
 2b6NGNzXfTYexzJ+nU7/ALkf4P8Awv6P9KvTQQ4AgyDqCF85Pho3CTB7eHwXoH+LT65uZbX9X+o2
 bqbPb06551Y4
 `
-       encodedShort := strings.Replace(encoded, "\n", "", -1)
+       encodedShort := strings.ReplaceAll(encoded, "\n", "")
 
        dec := NewDecoder(StdEncoding, strings.NewReader(encoded))
        res1, err := ioutil.ReadAll(dec)
index 2cd7829c1a69b8230ff74a88246a04bb62cf26ad..ae84e1f775e926c32143174c7afe8b378d122bcb 100644 (file)
@@ -472,7 +472,7 @@ func (f *FlagSet) PrintDefaults() {
                        // for both 4- and 8-space tab stops.
                        s += "\n    \t"
                }
-               s += strings.Replace(usage, "\n", "\n    \t", -1)
+               s += strings.ReplaceAll(usage, "\n", "\n    \t")
 
                if !isZeroValue(flag, flag.DefValue) {
                        if _, ok := flag.Value.(*stringValue); ok {
index e6fca76e182bc8f15b866015c0e54c963329b35c..68b87eaa5571d88d50b4976511f512f1cea89834 100644 (file)
@@ -296,7 +296,7 @@ func val(lit string) Value {
        switch first, last := lit[0], lit[len(lit)-1]; {
        case first == '"' || first == '`':
                tok = token.STRING
-               lit = strings.Replace(lit, "_", " ", -1)
+               lit = strings.ReplaceAll(lit, "_", " ")
        case first == '\'':
                tok = token.CHAR
        case last == 'i':
index 902a79f63f59a40fcb8e9bfe4c44255e9faf110c..0b2d2b63ccc0902653e95d9171089eefe8e902b2 100644 (file)
@@ -40,7 +40,7 @@ func readTemplate(filename string) *template.Template {
 func nodeFmt(node interface{}, fset *token.FileSet) string {
        var buf bytes.Buffer
        printer.Fprint(&buf, fset, node)
-       return strings.Replace(strings.TrimSpace(buf.String()), "\n", "\n\t", -1)
+       return strings.ReplaceAll(strings.TrimSpace(buf.String()), "\n", "\n\t")
 }
 
 func synopsisFmt(s string) string {
@@ -53,7 +53,7 @@ func synopsisFmt(s string) string {
                }
                s = strings.TrimSpace(s) + " ..."
        }
-       return "// " + strings.Replace(s, "\n", " ", -1)
+       return "// " + strings.ReplaceAll(s, "\n", " ")
 }
 
 func indentFmt(indent, s string) string {
@@ -62,7 +62,7 @@ func indentFmt(indent, s string) string {
                end = "\n"
                s = s[:len(s)-1]
        }
-       return indent + strings.Replace(s, "\n", "\n"+indent, -1) + end
+       return indent + strings.ReplaceAll(s, "\n", "\n"+indent) + end
 }
 
 func isGoFile(fi os.FileInfo) bool {
index e570040ba1f6db8781b6099642988cdc23936564..30816931a8b2f546bece4ea54ed0fd85b4008979 100644 (file)
@@ -48,7 +48,7 @@ func ExampleFprint() {
        // and trim leading and trailing white space.
        s := buf.String()
        s = s[1 : len(s)-1]
-       s = strings.TrimSpace(strings.Replace(s, "\n\t", "\n", -1))
+       s = strings.TrimSpace(strings.ReplaceAll(s, "\n\t", "\n"))
 
        // Print the cleaned-up body text to stdout.
        fmt.Println(s)
@@ -61,7 +61,7 @@ func ExampleFprint() {
        //
        // s := buf.String()
        // s = s[1 : len(s)-1]
-       // s = strings.TrimSpace(strings.Replace(s, "\n\t", "\n", -1))
+       // s = strings.TrimSpace(strings.ReplaceAll(s, "\n\t", "\n"))
        //
        // fmt.Println(s)
 }
index 33a18b41864cc7d649e1925b3352b7148d83d18e..2291f47c33ed856c560717298000a3b254df552e 100644 (file)
@@ -172,7 +172,7 @@ func jsValEscaper(args ...interface{}) string {
                // turning into
                //     x//* error marshaling y:
                //          second line of error message */null
-               return fmt.Sprintf(" /* %s */null ", strings.Replace(err.Error(), "*/", "* /", -1))
+               return fmt.Sprintf(" /* %s */null ", strings.ReplaceAll(err.Error(), "*/", "* /"))
        }
 
        // TODO: maybe post-process output to prevent it from containing
index f0516300deb8ccd860644b8f881692d635b68253..8a4f727e50f252cf2c24e2b2ad5c17b3e4760f3f 100644 (file)
@@ -156,7 +156,7 @@ func srcsetFilterAndEscaper(args ...interface{}) string {
                        s = b.String()
                }
                // Additionally, commas separate one source from another.
-               return strings.Replace(s, ",", "%2c", -1)
+               return strings.ReplaceAll(s, ",", "%2c")
        }
 
        var b bytes.Buffer
index 2d6a830cb669b791999aa98ef603272aa806bb6c..105a82c417063c997293579d4c72f5e1b50ea189 100644 (file)
@@ -13,7 +13,7 @@ import (
 )
 
 func TestReadForm(t *testing.T) {
-       b := strings.NewReader(strings.Replace(message, "\n", "\r\n", -1))
+       b := strings.NewReader(strings.ReplaceAll(message, "\n", "\r\n"))
        r := NewReader(b, boundary)
        f, err := r.ReadForm(25)
        if err != nil {
@@ -39,7 +39,7 @@ func TestReadForm(t *testing.T) {
 }
 
 func TestReadFormWithNamelessFile(t *testing.T) {
-       b := strings.NewReader(strings.Replace(messageWithFileWithoutName, "\n", "\r\n", -1))
+       b := strings.NewReader(strings.ReplaceAll(messageWithFileWithoutName, "\n", "\r\n"))
        r := NewReader(b, boundary)
        f, err := r.ReadForm(25)
        if err != nil {
@@ -54,7 +54,7 @@ func TestReadFormWithNamelessFile(t *testing.T) {
 
 func TestReadFormWithTextContentType(t *testing.T) {
        // From https://github.com/golang/go/issues/24041
-       b := strings.NewReader(strings.Replace(messageWithTextContentType, "\n", "\r\n", -1))
+       b := strings.NewReader(strings.ReplaceAll(messageWithTextContentType, "\n", "\r\n"))
        r := NewReader(b, boundary)
        f, err := r.ReadForm(25)
        if err != nil {
@@ -184,7 +184,7 @@ Content-Disposition: form-data; name="largetext"
 --MyBoundary--
 `
 
-       testBody := strings.Replace(message, "\n", "\r\n", -1)
+       testBody := strings.ReplaceAll(message, "\n", "\r\n")
        testCases := []struct {
                name      string
                maxMemory int64
index abe1cc8e77cc74e1d3672f19436982358a7373c4..7bf606765ce9eea94f2872621bb1cf11f306e897 100644 (file)
@@ -105,7 +105,7 @@ never read data
 
 useless trailer
 `
-       testBody = strings.Replace(testBody, "\n", sep, -1)
+       testBody = strings.ReplaceAll(testBody, "\n", sep)
        return strings.Replace(testBody, "[longline]", longLine, 1)
 }
 
@@ -151,7 +151,7 @@ func testMultipart(t *testing.T, r io.Reader, onlyNewlines bool) {
 
        adjustNewlines := func(s string) string {
                if onlyNewlines {
-                       return strings.Replace(s, "\r\n", "\n", -1)
+                       return strings.ReplaceAll(s, "\r\n", "\n")
                }
                return s
        }
@@ -299,7 +299,7 @@ foo-bar: baz
 
 Oh no, premature EOF!
 `
-       body := strings.Replace(testBody, "\n", "\r\n", -1)
+       body := strings.ReplaceAll(testBody, "\n", "\r\n")
        bodyReader := strings.NewReader(body)
        r := NewReader(bodyReader, "MyBoundary")
 
index da12ac34980b8004109e3a9de756b83ecf8f297f..10325c2eb5ae023d7a511c1abfb85408f1c0777a 100644 (file)
@@ -86,7 +86,7 @@ func RequestFromMap(params map[string]string) (*http.Request, error) {
                if !strings.HasPrefix(k, "HTTP_") || k == "HTTP_HOST" {
                        continue
                }
-               r.Header.Add(strings.Replace(k[5:], "_", "-", -1), v)
+               r.Header.Add(strings.ReplaceAll(k[5:], "_", "-"), v)
        }
 
        // TODO: cookies.  parsing them isn't exported, though.
index 5703a7fb866a0acb2a9dfe35c2d2d44a6f38fe0c..63312dd885690ce6a66569dfe3cc166d23c35876 100644 (file)
@@ -370,7 +370,7 @@ func TestDumpResponse(t *testing.T) {
                }
                got := string(gotb)
                got = strings.TrimSpace(got)
-               got = strings.Replace(got, "\r", "", -1)
+               got = strings.ReplaceAll(got, "\r", "")
 
                if got != tt.want {
                        t.Errorf("%d.\nDumpResponse got:\n%s\n\nWant:\n%s\n", i, got, tt.want)
index 18eed345a842238dcb83400542d255f3048ad9b6..517a8189e1580e4cda640757e44da0c5d4ba7c03 100644 (file)
@@ -438,7 +438,7 @@ func TestReadRequest(t *testing.T) {
 // reqBytes treats req as a request (with \n delimiters) and returns it with \r\n delimiters,
 // ending in \r\n\r\n
 func reqBytes(req string) []byte {
-       return []byte(strings.Replace(strings.TrimSpace(req), "\n", "\r\n", -1) + "\r\n\r\n")
+       return []byte(strings.ReplaceAll(strings.TrimSpace(req), "\n", "\r\n") + "\r\n\r\n")
 }
 
 var badRequestTests = []struct {
index 7a83ae5b1cef372b4bbf979320a38248f095b48d..e8005571df9757dec7e32cc723bd28752dd6e216 100644 (file)
@@ -878,7 +878,7 @@ func testMissingFile(t *testing.T, req *Request) {
 }
 
 func newTestMultipartRequest(t *testing.T) *Request {
-       b := strings.NewReader(strings.Replace(message, "\n", "\r\n", -1))
+       b := strings.NewReader(strings.ReplaceAll(message, "\n", "\r\n"))
        req, err := NewRequest("POST", "/", b)
        if err != nil {
                t.Fatal("NewRequest:", err)
@@ -970,8 +970,8 @@ Content-Disposition: form-data; name="textb"
 `
 
 func benchmarkReadRequest(b *testing.B, request string) {
-       request = request + "\n"                             // final \n
-       request = strings.Replace(request, "\n", "\r\n", -1) // expand \n to \r\n
+       request = request + "\n"                            // final \n
+       request = strings.ReplaceAll(request, "\n", "\r\n") // expand \n to \r\n
        b.SetBytes(int64(len(request)))
        r := bufio.NewReader(&infiniteReader{buf: []byte(request)})
        b.ReportAllocs()
index 8dae95678da299509a4d30d37b11a6652abb6b4e..b12fcf4f9eb2ecd1540d9639662170bf19d023fe 100644 (file)
@@ -130,7 +130,7 @@ func (c *testConn) Close() error {
 // reqBytes treats req as a request (with \n delimiters) and returns it with \r\n delimiters,
 // ending in \r\n\r\n
 func reqBytes(req string) []byte {
-       return []byte(strings.Replace(strings.TrimSpace(req), "\n", "\r\n", -1) + "\r\n\r\n")
+       return []byte(strings.ReplaceAll(strings.TrimSpace(req), "\n", "\r\n") + "\r\n\r\n")
 }
 
 type handlerTest struct {
index cebb2d0558976f578b2cbeb176e8504a614c15fd..d3748f28c3f98b59517a3fe9b0ce792e6ff3511b 100644 (file)
@@ -150,7 +150,7 @@ func nslookup(qtype, name string) (string, error) {
        if err := cmd.Run(); err != nil {
                return "", err
        }
-       r := strings.Replace(out.String(), "\r\n", "\n", -1)
+       r := strings.ReplaceAll(out.String(), "\r\n", "\n")
        // nslookup stderr output contains also debug information such as
        // "Non-authoritative answer" and it doesn't return the correct errcode
        if strings.Contains(err.String(), "can't find") {
index b19da52c423a7ffd08d8d3a84d89be7a5d4d8e87..14ac9192a4af0569e3ff3b5ce3c1a2e248dc9bd2 100644 (file)
@@ -668,9 +668,9 @@ func TestAddressParser(t *testing.T) {
 
                        switch charset {
                        case "iso-8859-15":
-                               in = bytes.Replace(in, []byte("\xf6"), []byte("ö"), -1)
+                               in = bytes.ReplaceAll(in, []byte("\xf6"), []byte("ö"))
                        case "windows-1252":
-                               in = bytes.Replace(in, []byte("\xe9"), []byte("é"), -1)
+                               in = bytes.ReplaceAll(in, []byte("\xe9"), []byte("é"))
                        }
 
                        return bytes.NewReader(in), nil
index 8dfd3129802c29722be72b0545d6d4bcc313e567..8aa719f433afae84888c079e42c780a3240ccd27 100644 (file)
@@ -571,7 +571,7 @@ func TestInterfaceHardwareAddrWithGetmac(t *testing.T) {
                        // skip these
                        return
                }
-               addr = strings.Replace(addr, "-", ":", -1)
+               addr = strings.ReplaceAll(addr, "-", ":")
                cname := getValue("Connection Name")
                want[cname] = addr
                group = make(map[string]string)
index d8eb6dcd20c7b15d5393b1a8fd03fb1a6e9c92b3..ad67f5328a8688cd5104d2067098c14e2eb51bf8 100644 (file)
@@ -219,5 +219,5 @@ func toJSON(m interface{}) string {
        if err != nil {
                log.Fatal(err)
        }
-       return strings.Replace(string(js), ",", ", ", -1)
+       return strings.ReplaceAll(string(js), ",", ", ")
 }
index 5d3f91248f42e1bc0940edc479042fef6d1a5822..7c4ada245a7a3d9f34501711f367378c66c9e2e2 100644 (file)
@@ -848,18 +848,18 @@ func TestUnescape(t *testing.T) {
                in := tt.in
                out := tt.out
                if strings.Contains(tt.in, "+") {
-                       in = strings.Replace(tt.in, "+", "%20", -1)
+                       in = strings.ReplaceAll(tt.in, "+", "%20")
                        actual, err := PathUnescape(in)
                        if actual != tt.out || (err != nil) != (tt.err != nil) {
                                t.Errorf("PathUnescape(%q) = %q, %s; want %q, %s", in, actual, err, tt.out, tt.err)
                        }
                        if tt.err == nil {
-                               s, err := QueryUnescape(strings.Replace(tt.in, "+", "XXX", -1))
+                               s, err := QueryUnescape(strings.ReplaceAll(tt.in, "+", "XXX"))
                                if err != nil {
                                        continue
                                }
                                in = tt.in
-                               out = strings.Replace(s, "XXX", "+", -1)
+                               out = strings.ReplaceAll(s, "XXX", "+")
                        }
                }
 
index 00a3e63bf3ceca6963711734b60159a9c97ae450..f1745ad132e764b568cb6e5b4efce66db925a3c0 100644 (file)
@@ -38,10 +38,10 @@ func TestFixLongPath(t *testing.T) {
                {`\\?\c:\long\foo.txt`, `\\?\c:\long\foo.txt`},
                {`\\?\c:\long/foo.txt`, `\\?\c:\long/foo.txt`},
        } {
-               in := strings.Replace(test.in, "long", veryLong, -1)
-               want := strings.Replace(test.want, "long", veryLong, -1)
+               in := strings.ReplaceAll(test.in, "long", veryLong)
+               want := strings.ReplaceAll(test.want, "long", veryLong)
                if got := os.FixLongPath(in); got != want {
-                       got = strings.Replace(got, veryLong, "long", -1)
+                       got = strings.ReplaceAll(got, veryLong, "long")
                        t.Errorf("fixLongPath(%q) = %q; want %q", test.in, got, test.want)
                }
        }
index 1508137a33d1dd255b12b531e75a2c29d0694b5e..aba1717e7d5e0c7186a0e2a91adb011730d71f0e 100644 (file)
@@ -166,7 +166,7 @@ func ToSlash(path string) string {
        if Separator == '/' {
                return path
        }
-       return strings.Replace(path, string(Separator), "/", -1)
+       return strings.ReplaceAll(path, string(Separator), "/")
 }
 
 // FromSlash returns the result of replacing each slash ('/') character
@@ -176,7 +176,7 @@ func FromSlash(path string) string {
        if Separator == '/' {
                return path
        }
-       return strings.Replace(path, "/", string(Separator), -1)
+       return strings.ReplaceAll(path, "/", string(Separator))
 }
 
 // SplitList splits a list of paths joined by the OS-specific ListSeparator,
index a221a3d4fac64651611f19648da2156741832bf7..e1b5ad1d40c9c4e9f656314f1086de430b40413a 100644 (file)
@@ -1062,7 +1062,7 @@ func TestAbs(t *testing.T) {
        }
 
        for _, path := range absTests {
-               path = strings.Replace(path, "$", root, -1)
+               path = strings.ReplaceAll(path, "$", root)
                info, err := os.Stat(path)
                if err != nil {
                        t.Errorf("%s: %s", path, err)
index 519b6ebc329cc38052cb83e10fa35623c9dd85bf..6a144d9e0b5fae425e66cddc20f179b3c6413df9 100644 (file)
@@ -100,7 +100,7 @@ func splitList(path string) []string {
 
        // Remove quotes.
        for i, s := range list {
-               list[i] = strings.Replace(s, `"`, ``, -1)
+               list[i] = strings.ReplaceAll(s, `"`, ``)
        }
 
        return list
index e36a3c9b646367e69ec9a0a1a58f37e90612e028..63eab18116cf5d44213cec00a8471c45309ce1d6 100644 (file)
@@ -431,7 +431,7 @@ func TestToNorm(t *testing.T) {
                t.Fatal(err)
        }
 
-       err = os.MkdirAll(strings.Replace(testPath, "{{tmp}}", ctmp, -1), 0777)
+       err = os.MkdirAll(strings.ReplaceAll(testPath, "{{tmp}}", ctmp), 0777)
        if err != nil {
                t.Fatal(err)
        }
index 64c3e3f054d380b6324a8dae217aaef90b2ef053..863bd403a445d0c7857a67927b995262a01940a8 100644 (file)
@@ -200,7 +200,7 @@ var libRx = regexp.MustCompile(`([.]so$|[.]so[._][0-9]+)`)
 // first.
 func (p *Profile) setMain() {
        for i := 0; i < len(p.Mapping); i++ {
-               file := strings.TrimSpace(strings.Replace(p.Mapping[i].File, "(deleted)", "", -1))
+               file := strings.TrimSpace(strings.ReplaceAll(p.Mapping[i].File, "(deleted)", ""))
                if len(file) == 0 {
                        continue
                }
index 126ba50054e57c0afeeac09222a41e22f97727a7..593924183f67e8bd7357197f110efac638270a60 100644 (file)
@@ -602,7 +602,7 @@ func TestBlockProfile(t *testing.T) {
                }
 
                for _, test := range tests {
-                       if !regexp.MustCompile(strings.Replace(test.re, "\t", "\t+", -1)).MatchString(prof) {
+                       if !regexp.MustCompile(strings.ReplaceAll(test.re, "\t", "\t+")).MatchString(prof) {
                                t.Errorf("Bad %v entry, expect:\n%v\ngot:\n%v", test.name, test.re, prof)
                        }
                }
index 1ed6b3930384e1a286a0df26d6aaa1d4c3e59a46..26f507159b8a650fc0252e9d7d526fe659828be0 100644 (file)
@@ -490,7 +490,7 @@ func TestGdbConst(t *testing.T) {
        }
        got, _ := exec.Command("gdb", args...).CombinedOutput()
 
-       sgot := strings.Replace(string(got), "\r\n", "\n", -1)
+       sgot := strings.ReplaceAll(string(got), "\r\n", "\n")
 
        t.Logf("output %q", sgot)
 
index 607e4a0a70e7afdcc6bff41a723f6ca966e28e3a..103ef51f29edb758fa4e1ac88086be67779a3ab4 100644 (file)
@@ -199,7 +199,7 @@ func ExampleRepeat() {
 
 func ExampleReplace() {
        fmt.Println(strings.Replace("oink oink oink", "k", "ky", 2))
-       fmt.Println(strings.Replace("oink oink oink", "oink", "moo", -1))
+       fmt.Println(strings.ReplaceAll("oink oink oink", "oink", "moo"))
        // Output:
        // oinky oinky oink
        // moo moo moo
index 9af3909b3556e44c6db6870cb43f15c0e98bf6d2..29803c06e2f9c2d3e3f4f8bf06535fa1492cafc8 100644 (file)
@@ -594,8 +594,8 @@ func TestBRun(t *T) {
 
 func makeRegexp(s string) string {
        s = regexp.QuoteMeta(s)
-       s = strings.Replace(s, ":NNN:", `:\d\d\d:`, -1)
-       s = strings.Replace(s, "N\\.NNs", `\d*\.\d*s`, -1)
+       s = strings.ReplaceAll(s, ":NNN:", `:\d\d\d:`)
+       s = strings.ReplaceAll(s, "N\\.NNs", `\d*\.\d*s`)
        return s
 }
 
index 214f72d51b32ac258895cfb645584d1b1df47e49..1d04c2982f806f2ecc60fe50d8dc37e793720759 100644 (file)
@@ -102,7 +102,7 @@ func (s *state) at(node parse.Node) {
 // doublePercent returns the string with %'s replaced by %%, if necessary,
 // so it can be used safely inside a Printf format string.
 func doublePercent(str string) string {
-       return strings.Replace(str, "%", "%%", -1)
+       return strings.ReplaceAll(str, "%", "%%")
 }
 
 // TODO: It would be nice if ExecError was more broken down, but