mirror of
https://github.com/golang/go
synced 2024-11-22 19:44:57 -07:00
cmd/go/internal/modload: don't use strings.TrimPrefix in *MainModuleSet.DirImportPath
To avoid calling strings.HasPrefix twice, don't use strings.TrimPrefix.
This commit is contained in:
parent
6a7ef36466
commit
74bcfff3fb
@ -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