mirror of
https://github.com/golang/go
synced 2024-11-26 10:58:16 -07:00
cmd/go/internal/modload: avoid calling strings.HasPrefix twice in *MainModuleSet.DirImportPath
Since TrimPrefix uses HasPrefix internally.
Change-Id: Ifadb99dd9192578056636adacaccc9d88a1c1f32
GitHub-Last-Rev: 74bcfff3fb
GitHub-Pull-Request: golang/go#63893
Reviewed-on: https://go-review.googlesource.com/c/go/+/539096
Run-TryBot: Jes Cok <xigua67damn@gmail.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
374a56ca33
commit
ba0dd3b328
@ -777,7 +777,7 @@ func (mms *MainModuleSet) DirImportPath(ctx context.Context, dir string) (path s
|
||||
longestPrefixVersion = v
|
||||
suffix := filepath.ToSlash(str.TrimFilePathPrefix(dir, modRoot))
|
||||
if strings.HasPrefix(suffix, "vendor/") {
|
||||
longestPrefixPath = strings.TrimPrefix(suffix, "vendor/")
|
||||
longestPrefixPath = suffix[len("vendor/"):]
|
||||
continue
|
||||
}
|
||||
longestPrefixPath = pathpkg.Join(mms.PathPrefix(v), suffix)
|
||||
|
Loading…
Reference in New Issue
Block a user