Skip to content

Commit 74bcfff

Browse files
committed
cmd/go/internal/modload: don't use strings.TrimPrefix in *MainModuleSet.DirImportPath
To avoid calling strings.HasPrefix twice, don't use strings.TrimPrefix.
1 parent 6a7ef36 commit 74bcfff

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cmd/go/internal/modload/load.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ func (mms *MainModuleSet) DirImportPath(ctx context.Context, dir string) (path s
777777
longestPrefixVersion = v
778778
suffix := filepath.ToSlash(str.TrimFilePathPrefix(dir, modRoot))
779779
if strings.HasPrefix(suffix, "vendor/") {
780-
longestPrefixPath = strings.TrimPrefix(suffix, "vendor/")
780+
longestPrefixPath = suffix[len("vendor/"):]
781781
continue
782782
}
783783
longestPrefixPath = pathpkg.Join(mms.PathPrefix(v), suffix)

0 commit comments

Comments
 (0)