aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/load/pkg.go
diff options
context:
space:
mode:
authorqiulaidongfeng <2645477756@qq.com>2023-09-09 00:58:21 +0000
committerGopher Robot <gobot@golang.org>2023-09-11 20:12:18 +0000
commitdfb2e4265bf7654001c77925dfbbb9c38c0d1a95 (patch)
tree83ee76b1fd2c7aea9a870155550a634ad7eb55ed /src/cmd/go/internal/load/pkg.go
parentafa3f8e104744ea2350b0eb87474866ef27e04f2 (diff)
downloadgo-dfb2e4265bf7654001c77925dfbbb9c38c0d1a95.tar.gz
go-dfb2e4265bf7654001c77925dfbbb9c38c0d1a95.zip
cmd/go: cache results of exec.LookPath
This CL package exec.LookPath to internal/cfg.LookPath and adds cache. BenchmarkLookPath-4 24149096 50.48 ns/op 0 B/op 0 allocs/op Fixes #36768 Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9 Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9 GitHub-Last-Rev: d67aa826f431affe829c23d1fdf2241fbb611303 GitHub-Pull-Request: golang/go#61464 Reviewed-on: https://go-review.googlesource.com/c/go/+/511458 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd/go/internal/load/pkg.go')
-rw-r--r--src/cmd/go/internal/load/pkg.go3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go
index 33e46f5f65..3e852603c4 100644
--- a/src/cmd/go/internal/load/pkg.go
+++ b/src/cmd/go/internal/load/pkg.go
@@ -18,7 +18,6 @@ import (
"internal/platform"
"io/fs"
"os"
- "os/exec"
pathpkg "path"
"path/filepath"
"runtime"
@@ -2483,7 +2482,7 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS bool) {
goto omitVCS
}
if cfg.BuildBuildvcs == "auto" && vcsCmd != nil && vcsCmd.Cmd != "" {
- if _, err := exec.LookPath(vcsCmd.Cmd); err != nil {
+ if _, err := cfg.LookPath(vcsCmd.Cmd); err != nil {
// We fould a repository, but the required VCS tool is not present.
// "-buildvcs=auto" means that we should silently drop the VCS metadata.
goto omitVCS