diff options
| author | Nathan VanBenschoten <nvanbenschoten@gmail.com> | 2015-12-22 02:40:47 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2016-02-19 01:06:05 +0000 |
| commit | b04f3b06ec347543b0eafe82dcfb0e05885d3feb (patch) | |
| tree | c9d889546ef895fce8b8a2c04c7e06cc998c1842 /src/path/filepath | |
| parent | 952c2fd606fad19b930937ca0d5c5571d7f5d4cb (diff) | |
| download | go-b04f3b06ec347543b0eafe82dcfb0e05885d3feb.tar.xz | |
all: replace strings.Index with strings.Contains where possible
Change-Id: Ia613f1c37bfce800ece0533a5326fca91d99a66a
Reviewed-on: https://go-review.googlesource.com/18120
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/path/filepath')
| -rw-r--r-- | src/path/filepath/match.go | 4 | ||||
| -rw-r--r-- | src/path/filepath/match_test.go | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/path/filepath/match.go b/src/path/filepath/match.go index 89f16de355..d64bf84fc0 100644 --- a/src/path/filepath/match.go +++ b/src/path/filepath/match.go @@ -49,7 +49,7 @@ Pattern: star, chunk, pattern = scanChunk(pattern) if star && chunk == "" { // Trailing * matches rest of string unless it has a /. - return strings.Index(name, string(Separator)) < 0, nil + return !strings.Contains(name, string(Separator)), nil } // Look for match at current position. t, ok, err := matchChunk(chunk, name) @@ -305,5 +305,5 @@ func glob(dir, pattern string, matches []string) (m []string, e error) { // recognized by Match. func hasMeta(path string) bool { // TODO(niemeyer): Should other magic characters be added here? - return strings.IndexAny(path, "*?[") >= 0 + return strings.ContainsAny(path, "*?[") } diff --git a/src/path/filepath/match_test.go b/src/path/filepath/match_test.go index 0edbfc70c4..d8bab7f4da 100644 --- a/src/path/filepath/match_test.go +++ b/src/path/filepath/match_test.go @@ -88,7 +88,7 @@ func TestMatch(t *testing.T) { pattern := tt.pattern s := tt.s if runtime.GOOS == "windows" { - if strings.Index(pattern, "\\") >= 0 { + if strings.Contains(pattern, "\\") { // no escape allowed on windows. continue } |
