all: use strings.ReplaceAll and bytes.ReplaceAll where applicable

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>
diff --git a/src/cmd/fix/main.go b/src/cmd/fix/main.go
index f06abae..f54a5e0 100644
--- a/src/cmd/fix/main.go
+++ b/src/cmd/fix/main.go
@@ -52,7 +52,7 @@
 			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)
diff --git a/src/cmd/fix/typecheck.go b/src/cmd/fix/typecheck.go
index eafb626..66e0cdc 100644
--- a/src/cmd/fix/typecheck.go
+++ b/src/cmd/fix/typecheck.go
@@ -193,12 +193,12 @@
 					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)
diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go
index 962b52f..139ee73 100644
--- a/src/cmd/go/go_test.go
+++ b/src/cmd/go/go_test.go
@@ -1090,7 +1090,7 @@
 		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 @@
 
 	// 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 @@
 
 	// 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 @@
 
 	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))
 	}
diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go
index afadbad..85a42e0 100644
--- a/src/cmd/go/internal/envcmd/env.go
+++ b/src/cmd/go/internal/envcmd/env.go
@@ -203,7 +203,7 @@
 				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)
diff --git a/src/cmd/go/internal/get/vcs.go b/src/cmd/go/internal/get/vcs.go
index 0f7b623..173934b 100644
--- a/src/cmd/go/internal/get/vcs.go
+++ b/src/cmd/go/internal/get/vcs.go
@@ -964,7 +964,7 @@
 // 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
 }
diff --git a/src/cmd/go/internal/modconv/convert_test.go b/src/cmd/go/internal/modconv/convert_test.go
index ad27abb..4d55d73 100644
--- a/src/cmd/go/internal/modconv/convert_test.go
+++ b/src/cmd/go/internal/modconv/convert_test.go
@@ -146,7 +146,7 @@
 	}
 
 	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)
diff --git a/src/cmd/go/internal/modfetch/codehost/codehost.go b/src/cmd/go/internal/modfetch/codehost/codehost.go
index 4103ddc..4205cd2 100644
--- a/src/cmd/go/internal/modfetch/codehost/codehost.go
+++ b/src/cmd/go/internal/modfetch/codehost/codehost.go
@@ -185,7 +185,7 @@
 	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
 }
diff --git a/src/cmd/go/internal/modfetch/coderepo_test.go b/src/cmd/go/internal/modfetch/coderepo_test.go
index 79b8278..0b62b9e 100644
--- a/src/cmd/go/internal/modfetch/coderepo_test.go
+++ b/src/cmd/go/internal/modfetch/coderepo_test.go
@@ -423,7 +423,7 @@
 				}
 			}
 		}
-		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 @@
 				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 @@
 		}
 	}
 	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 @@
 	}
 	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 @@
 	}
 	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 {
diff --git a/src/cmd/go/internal/modfetch/proxy.go b/src/cmd/go/internal/modfetch/proxy.go
index 5f856b8..7c78502 100644
--- a/src/cmd/go/internal/modfetch/proxy.go
+++ b/src/cmd/go/internal/modfetch/proxy.go
@@ -248,5 +248,5 @@
 // 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", "/")
 }
diff --git a/src/cmd/go/internal/modload/import_test.go b/src/cmd/go/internal/modload/import_test.go
index 3f4ddab..9422a3d 100644
--- a/src/cmd/go/internal/modload/import_test.go
+++ b/src/cmd/go/internal/modload/import_test.go
@@ -45,7 +45,7 @@
 	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 {
diff --git a/src/cmd/go/internal/modload/query_test.go b/src/cmd/go/internal/modload/query_test.go
index 7f3ffab..9b07383 100644
--- a/src/cmd/go/internal/modload/query_test.go
+++ b/src/cmd/go/internal/modload/query_test.go
@@ -132,7 +132,7 @@
 			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 {
diff --git a/src/cmd/go/internal/search/search.go b/src/cmd/go/internal/search/search.go
index 60ae736..0ca60e7 100644
--- a/src/cmd/go/internal/search/search.go
+++ b/src/cmd/go/internal/search/search.go
@@ -275,7 +275,7 @@
 	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 @@
 		// 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 ./.
diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go
index dd482b6..145b875 100644
--- a/src/cmd/go/internal/work/build.go
+++ b/src/cmd/go/internal/work/build.go
@@ -398,10 +398,10 @@
 					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
diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
index 01414a3..158f5f3 100644
--- a/src/cmd/go/internal/work/exec.go
+++ b/src/cmd/go/internal/work/exec.go
@@ -1705,14 +1705,14 @@
 		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 @@
 	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...)
diff --git a/src/cmd/go/proxy_test.go b/src/cmd/go/proxy_test.go
index 212e5aa..97fc4b0 100644
--- a/src/cmd/go/proxy_test.go
+++ b/src/cmd/go/proxy_test.go
@@ -78,7 +78,7 @@
 		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 @@
 		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)
diff --git a/src/cmd/go/script_test.go b/src/cmd/go/script_test.go
index 7c083a8..31c6ede 100644
--- a/src/cmd/go/script_test.go
+++ b/src/cmd/go/script_test.go
@@ -329,7 +329,7 @@
 		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 @@
 	}
 
 	// 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 @@
 
 // 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 @@
 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)
 		}
diff --git a/src/cmd/go/testdata/addmod.go b/src/cmd/go/testdata/addmod.go
index 19850af..8bb6056 100644
--- a/src/cmd/go/testdata/addmod.go
+++ b/src/cmd/go/testdata/addmod.go
@@ -142,7 +142,7 @@
 		}
 
 		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
diff --git a/src/cmd/go/vendor_test.go b/src/cmd/go/vendor_test.go
index 22aa643..c302d7e 100644
--- a/src/cmd/go/vendor_test.go
+++ b/src/cmd/go/vendor_test.go
@@ -37,7 +37,7 @@
 		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()
diff --git a/src/cmd/gofmt/gofmt_test.go b/src/cmd/gofmt/gofmt_test.go
index 16b653b..3008365 100644
--- a/src/cmd/gofmt/gofmt_test.go
+++ b/src/cmd/gofmt/gofmt_test.go
@@ -200,7 +200,7 @@
 	}
 
 	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)
diff --git a/src/cmd/internal/goobj/read.go b/src/cmd/internal/goobj/read.go
index e39180c..2d618ee 100644
--- a/src/cmd/internal/goobj/read.go
+++ b/src/cmd/internal/goobj/read.go
@@ -293,7 +293,7 @@
 	// 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
diff --git a/src/cmd/trace/trace.go b/src/cmd/trace/trace.go
index 676b9ff..07fc433 100644
--- a/src/cmd/trace/trace.go
+++ b/src/cmd/trace/trace.go
@@ -38,7 +38,7 @@
 		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))
 
 }
diff --git a/src/cmd/vet/main.go b/src/cmd/vet/main.go
index 646adf4..6e88512 100644
--- a/src/cmd/vet/main.go
+++ b/src/cmd/vet/main.go
@@ -273,7 +273,7 @@
 	// 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()
diff --git a/src/cmd/vet/vet_test.go b/src/cmd/vet/vet_test.go
index 90665d77..df84d6c 100644
--- a/src/cmd/vet/vet_test.go
+++ b/src/cmd/vet/vet_test.go
@@ -243,7 +243,7 @@
 	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)
 		}
 	}
 
diff --git a/src/crypto/rsa/pss_test.go b/src/crypto/rsa/pss_test.go
index cae24e5..dfa8d8b 100644
--- a/src/crypto/rsa/pss_test.go
+++ b/src/crypto/rsa/pss_test.go
@@ -103,7 +103,7 @@
 			switch {
 			case len(line) == 0:
 				if len(partialValue) > 0 {
-					values <- strings.Replace(partialValue, " ", "", -1)
+					values <- strings.ReplaceAll(partialValue, " ", "")
 					partialValue = ""
 					lastWasValue = true
 				}
diff --git a/src/crypto/x509/root_darwin_arm_gen.go b/src/crypto/x509/root_darwin_arm_gen.go
index b5580d6..bc44124 100644
--- a/src/crypto/x509/root_darwin_arm_gen.go
+++ b/src/crypto/x509/root_darwin_arm_gen.go
@@ -154,9 +154,9 @@
 		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{
diff --git a/src/encoding/base32/base32_test.go b/src/encoding/base32/base32_test.go
index c5506ed..b74054b 100644
--- a/src/encoding/base32/base32_test.go
+++ b/src/encoding/base32/base32_test.go
@@ -425,7 +425,7 @@
 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 @@
 	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 @@
 
 			expected := testpair.encoded
 			if encoding.padChar == NoPadding {
-				expected = strings.Replace(expected, "=", "", -1)
+				expected = strings.ReplaceAll(expected, "=", "")
 			}
 
 			res := buf.String()
@@ -697,7 +697,7 @@
 		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 @@
 			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))
diff --git a/src/encoding/base64/base64_test.go b/src/encoding/base64/base64_test.go
index f019654..f7f312c 100644
--- a/src/encoding/base64/base64_test.go
+++ b/src/encoding/base64/base64_test.go
@@ -53,8 +53,8 @@
 
 // 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 @@
 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 @@
 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)
diff --git a/src/flag/flag.go b/src/flag/flag.go
index 2cd7829..ae84e1f 100644
--- a/src/flag/flag.go
+++ b/src/flag/flag.go
@@ -472,7 +472,7 @@
 			// 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 {
diff --git a/src/go/constant/value_test.go b/src/go/constant/value_test.go
index e6fca76..68b87ea 100644
--- a/src/go/constant/value_test.go
+++ b/src/go/constant/value_test.go
@@ -296,7 +296,7 @@
 	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':
diff --git a/src/go/doc/doc_test.go b/src/go/doc/doc_test.go
index 902a79f..0b2d2b6 100644
--- a/src/go/doc/doc_test.go
+++ b/src/go/doc/doc_test.go
@@ -40,7 +40,7 @@
 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 @@
 		}
 		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 @@
 		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 {
diff --git a/src/go/printer/example_test.go b/src/go/printer/example_test.go
index e570040b..3081693 100644
--- a/src/go/printer/example_test.go
+++ b/src/go/printer/example_test.go
@@ -48,7 +48,7 @@
 	// 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 @@
 	//
 	// 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)
 }
diff --git a/src/html/template/js.go b/src/html/template/js.go
index 33a18b4..2291f47 100644
--- a/src/html/template/js.go
+++ b/src/html/template/js.go
@@ -172,7 +172,7 @@
 		// 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
diff --git a/src/html/template/url.go b/src/html/template/url.go
index f051630..8a4f727 100644
--- a/src/html/template/url.go
+++ b/src/html/template/url.go
@@ -156,7 +156,7 @@
 			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
diff --git a/src/mime/multipart/formdata_test.go b/src/mime/multipart/formdata_test.go
index 2d6a830..105a82c 100644
--- a/src/mime/multipart/formdata_test.go
+++ b/src/mime/multipart/formdata_test.go
@@ -13,7 +13,7 @@
 )
 
 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 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 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 @@
 --MyBoundary--
 `
 
-	testBody := strings.Replace(message, "\n", "\r\n", -1)
+	testBody := strings.ReplaceAll(message, "\n", "\r\n")
 	testCases := []struct {
 		name      string
 		maxMemory int64
diff --git a/src/mime/multipart/multipart_test.go b/src/mime/multipart/multipart_test.go
index abe1cc8..7bf6067 100644
--- a/src/mime/multipart/multipart_test.go
+++ b/src/mime/multipart/multipart_test.go
@@ -105,7 +105,7 @@
 
 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 @@
 
 	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 @@
 
 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")
 
diff --git a/src/net/http/cgi/child.go b/src/net/http/cgi/child.go
index da12ac3..10325c2 100644
--- a/src/net/http/cgi/child.go
+++ b/src/net/http/cgi/child.go
@@ -86,7 +86,7 @@
 		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.
diff --git a/src/net/http/httputil/dump_test.go b/src/net/http/httputil/dump_test.go
index 5703a7f..63312dd 100644
--- a/src/net/http/httputil/dump_test.go
+++ b/src/net/http/httputil/dump_test.go
@@ -370,7 +370,7 @@
 		}
 		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)
diff --git a/src/net/http/readrequest_test.go b/src/net/http/readrequest_test.go
index 18eed34..517a818 100644
--- a/src/net/http/readrequest_test.go
+++ b/src/net/http/readrequest_test.go
@@ -438,7 +438,7 @@
 // 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 {
diff --git a/src/net/http/request_test.go b/src/net/http/request_test.go
index 7a83ae5..e800557 100644
--- a/src/net/http/request_test.go
+++ b/src/net/http/request_test.go
@@ -878,7 +878,7 @@
 }
 
 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 @@
 `
 
 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()
diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go
index 8dae956..b12fcf4 100644
--- a/src/net/http/serve_test.go
+++ b/src/net/http/serve_test.go
@@ -130,7 +130,7 @@
 // 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 {
diff --git a/src/net/lookup_windows_test.go b/src/net/lookup_windows_test.go
index cebb2d0..d3748f2 100644
--- a/src/net/lookup_windows_test.go
+++ b/src/net/lookup_windows_test.go
@@ -150,7 +150,7 @@
 	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") {
diff --git a/src/net/mail/message_test.go b/src/net/mail/message_test.go
index b19da52..14ac919 100644
--- a/src/net/mail/message_test.go
+++ b/src/net/mail/message_test.go
@@ -668,9 +668,9 @@
 
 			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
diff --git a/src/net/net_windows_test.go b/src/net/net_windows_test.go
index 8dfd312..8aa719f 100644
--- a/src/net/net_windows_test.go
+++ b/src/net/net_windows_test.go
@@ -571,7 +571,7 @@
 			// skip these
 			return
 		}
-		addr = strings.Replace(addr, "-", ":", -1)
+		addr = strings.ReplaceAll(addr, "-", ":")
 		cname := getValue("Connection Name")
 		want[cname] = addr
 		group = make(map[string]string)
diff --git a/src/net/url/example_test.go b/src/net/url/example_test.go
index d8eb6dc..ad67f53 100644
--- a/src/net/url/example_test.go
+++ b/src/net/url/example_test.go
@@ -219,5 +219,5 @@
 	if err != nil {
 		log.Fatal(err)
 	}
-	return strings.Replace(string(js), ",", ", ", -1)
+	return strings.ReplaceAll(string(js), ",", ", ")
 }
diff --git a/src/net/url/url_test.go b/src/net/url/url_test.go
index 5d3f912..7c4ada2 100644
--- a/src/net/url/url_test.go
+++ b/src/net/url/url_test.go
@@ -848,18 +848,18 @@
 		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", "+")
 			}
 		}
 
diff --git a/src/os/path_windows_test.go b/src/os/path_windows_test.go
index 00a3e63..f1745ad 100644
--- a/src/os/path_windows_test.go
+++ b/src/os/path_windows_test.go
@@ -38,10 +38,10 @@
 		{`\\?\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)
 		}
 	}
diff --git a/src/path/filepath/path.go b/src/path/filepath/path.go
index 1508137..aba1717 100644
--- a/src/path/filepath/path.go
+++ b/src/path/filepath/path.go
@@ -166,7 +166,7 @@
 	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 @@
 	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,
diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go
index a221a3d..e1b5ad1 100644
--- a/src/path/filepath/path_test.go
+++ b/src/path/filepath/path_test.go
@@ -1062,7 +1062,7 @@
 	}
 
 	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)
diff --git a/src/path/filepath/path_windows.go b/src/path/filepath/path_windows.go
index 519b6eb..6a144d9 100644
--- a/src/path/filepath/path_windows.go
+++ b/src/path/filepath/path_windows.go
@@ -100,7 +100,7 @@
 
 	// Remove quotes.
 	for i, s := range list {
-		list[i] = strings.Replace(s, `"`, ``, -1)
+		list[i] = strings.ReplaceAll(s, `"`, ``)
 	}
 
 	return list
diff --git a/src/path/filepath/path_windows_test.go b/src/path/filepath/path_windows_test.go
index e36a3c9..63eab18 100644
--- a/src/path/filepath/path_windows_test.go
+++ b/src/path/filepath/path_windows_test.go
@@ -431,7 +431,7 @@
 		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)
 	}
diff --git a/src/runtime/pprof/internal/profile/profile.go b/src/runtime/pprof/internal/profile/profile.go
index 64c3e3f..863bd40 100644
--- a/src/runtime/pprof/internal/profile/profile.go
+++ b/src/runtime/pprof/internal/profile/profile.go
@@ -200,7 +200,7 @@
 // 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
 		}
diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go
index 126ba50..5939241 100644
--- a/src/runtime/pprof/pprof_test.go
+++ b/src/runtime/pprof/pprof_test.go
@@ -602,7 +602,7 @@
 		}
 
 		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)
 			}
 		}
diff --git a/src/runtime/runtime-gdb_test.go b/src/runtime/runtime-gdb_test.go
index 1ed6b39..26f5071 100644
--- a/src/runtime/runtime-gdb_test.go
+++ b/src/runtime/runtime-gdb_test.go
@@ -490,7 +490,7 @@
 	}
 	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)
 
diff --git a/src/strings/example_test.go b/src/strings/example_test.go
index 607e4a0..103ef51 100644
--- a/src/strings/example_test.go
+++ b/src/strings/example_test.go
@@ -199,7 +199,7 @@
 
 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
diff --git a/src/testing/sub_test.go b/src/testing/sub_test.go
index 9af3909..29803c0 100644
--- a/src/testing/sub_test.go
+++ b/src/testing/sub_test.go
@@ -594,8 +594,8 @@
 
 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
 }
 
diff --git a/src/text/template/exec.go b/src/text/template/exec.go
index 214f72d..1d04c29 100644
--- a/src/text/template/exec.go
+++ b/src/text/template/exec.go
@@ -102,7 +102,7 @@
 // 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