1
0
mirror of https://github.com/golang/go synced 2024-07-08 20:29:48 +00:00

all: replace Replace(..., -1) with ReplaceAll(...)

Change-Id: I8f7cff7a83a9c50bfa3331e8b40e4a6c2e1c0eee
Reviewed-on: https://go-review.googlesource.com/c/go/+/245198
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Polina Osadcha 2020-06-18 16:17:13 +03:00 committed by Martin Möhrmann
parent f7fc25ed5a
commit 6f99b33c18
4 changed files with 4 additions and 4 deletions

View File

@ -105,7 +105,7 @@ func test(tmpdir, file, want string) error {
// Canonicalize output.
out = bytes.TrimRight(out, "\n")
out = bytes.Replace(out, []byte{'\n'}, []byte{' '}, -1)
out = bytes.ReplaceAll(out, []byte{'\n'}, []byte{' '})
// Check the result.
match, err := regexp.Match(want, out)

View File

@ -179,7 +179,7 @@ func TestCover(t *testing.T) {
}
lines := bytes.Split(file, []byte("\n"))
for i, line := range lines {
lines[i] = bytes.Replace(line, []byte("LINE"), []byte(fmt.Sprint(i+1)), -1)
lines[i] = bytes.ReplaceAll(line, []byte("LINE"), []byte(fmt.Sprint(i+1)))
}
// Add a function that is not gofmt'ed. This used to cause a crash.

View File

@ -138,7 +138,7 @@ func scanFile(file string, info os.FileInfo, mustPrint bool) {
fmt.Printf("%s: %s\n", file, vers)
if *versionM && mod != "" {
fmt.Printf("\t%s\n", strings.Replace(mod[:len(mod)-1], "\n", "\n\t", -1))
fmt.Printf("\t%s\n", strings.ReplaceAll(mod[:len(mod)-1], "\n", "\n\t"))
}
}

View File

@ -131,7 +131,7 @@ func header(arch string) {
func p(f string, args ...interface{}) {
fmted := fmt.Sprintf(f, args...)
fmt.Fprintf(out, "\t%s\n", strings.Replace(fmted, "\n", "\n\t", -1))
fmt.Fprintf(out, "\t%s\n", strings.ReplaceAll(fmted, "\n", "\n\t"))
}
func label(l string) {