aboutsummaryrefslogtreecommitdiff
path: root/src/path
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2018-09-26 21:10:21 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2018-09-26 22:14:25 +0000
commitda0d1a44bac379f5acedb1933f85400de08f4ac6 (patch)
tree20ac5d1ee7aeed87d3fa33f7e401309d62207f30 /src/path
parente35a41261b19589f40d32bd66274c23ab4b9b32e (diff)
downloadgo-da0d1a44bac379f5acedb1933f85400de08f4ac6.tar.gz
go-da0d1a44bac379f5acedb1933f85400de08f4ac6.zip
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>
Diffstat (limited to 'src/path')
-rw-r--r--src/path/filepath/path.go4
-rw-r--r--src/path/filepath/path_test.go2
-rw-r--r--src/path/filepath/path_windows.go2
-rw-r--r--src/path/filepath/path_windows_test.go2
4 files changed, 5 insertions, 5 deletions
diff --git a/src/path/filepath/path.go b/src/path/filepath/path.go
index 1508137a33..aba1717e7d 100644
--- a/src/path/filepath/path.go
+++ b/src/path/filepath/path.go
@@ -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,
diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go
index a221a3d4fa..e1b5ad1d40 100644
--- a/src/path/filepath/path_test.go
+++ b/src/path/filepath/path_test.go
@@ -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)
diff --git a/src/path/filepath/path_windows.go b/src/path/filepath/path_windows.go
index 519b6ebc32..6a144d9e0b 100644
--- a/src/path/filepath/path_windows.go
+++ b/src/path/filepath/path_windows.go
@@ -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
diff --git a/src/path/filepath/path_windows_test.go b/src/path/filepath/path_windows_test.go
index e36a3c9b64..63eab18116 100644
--- a/src/path/filepath/path_windows_test.go
+++ b/src/path/filepath/path_windows_test.go
@@ -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)
}