diff options
author | Jay Conrod <jayconrod@google.com> | 2019-10-23 13:47:36 -0400 |
---|---|---|
committer | Jay Conrod <jayconrod@google.com> | 2019-10-23 18:41:38 +0000 |
commit | 7833302a6258a65bc17526b54347601df5ff1c5e (patch) | |
tree | a06c0b5f59351d7eb8ee2e0bd14f472e6da5461e /src/cmd/go/internal/search/search.go | |
parent | 67fb5530f07ae77a5e2fe6b8f5dcf3305e117460 (diff) | |
download | go-7833302a6258a65bc17526b54347601df5ff1c5e.tar.gz go-7833302a6258a65bc17526b54347601df5ff1c5e.zip |
cmd/go: ignore '@' when cleaning local and absolute file path args
Since CL 194600, search.CleanPaths preserves characters after '@' in
each argument. This was done so that paths could be cleaned while
version queries were preserved. However, local and absolute file paths
may contain '@' characters.
With this change, '@' is treated as a normal character by
search.CleanPaths in local and absolute paths.
Fixes #35115
Change-Id: Ia7d37e0a2737442d4f1796cc2fc3a59237a8ddfe
Reviewed-on: https://go-review.googlesource.com/c/go/+/202761
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/internal/search/search.go')
-rw-r--r-- | src/cmd/go/internal/search/search.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/cmd/go/internal/search/search.go b/src/cmd/go/internal/search/search.go index 33ab4ae36e..ef3835bfa4 100644 --- a/src/cmd/go/internal/search/search.go +++ b/src/cmd/go/internal/search/search.go @@ -361,10 +361,10 @@ func ImportPathsQuiet(patterns []string) []*Match { return out } -// CleanPatterns returns the patterns to use for the given -// command line. It canonicalizes the patterns but does not -// evaluate any matches. It preserves text after '@' for commands -// that accept versions. +// CleanPatterns returns the patterns to use for the given command line. It +// canonicalizes the patterns but does not evaluate any matches. For patterns +// that are not local or absolute paths, it preserves text after '@' to avoid +// modifying version queries. func CleanPatterns(patterns []string) []string { if len(patterns) == 0 { return []string{"."} @@ -372,7 +372,9 @@ func CleanPatterns(patterns []string) []string { var out []string for _, a := range patterns { var p, v string - if i := strings.IndexByte(a, '@'); i < 0 { + if build.IsLocalImport(a) || filepath.IsAbs(a) { + p = a + } else if i := strings.IndexByte(a, '@'); i < 0 { p = a } else { p = a[:i] |