From 193f19ab5fa740638f50b6681c55e180af5995a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sat, 30 Aug 2025 15:39:17 +0100 Subject: [PATCH] use x/tools/cmd/bundle via `go tool` The behavior is the same, but now we track the dependency in go.mod via `go get -tool`, which is a better approach. While here, make a package loading error slightly clearer. --- go.mod | 2 ++ main.go | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 984adb1..3212398 100644 --- a/go.mod +++ b/go.mod @@ -17,3 +17,5 @@ require ( golang.org/x/sync v0.13.0 // indirect golang.org/x/sys v0.32.0 // indirect ) + +tool golang.org/x/tools/cmd/bundle diff --git a/main.go b/main.go index 3607add..125defb 100644 --- a/main.go +++ b/main.go @@ -436,7 +436,7 @@ func mainErr(args []string) error { toolexecImportPath := os.Getenv("TOOLEXEC_IMPORTPATH") tf.curPkg = sharedCache.ListedPackages[toolexecImportPath] if tf.curPkg == nil { - return fmt.Errorf("TOOLEXEC_IMPORTPATH not found in listed packages: %s", toolexecImportPath) + return fmt.Errorf("TOOLEXEC_IMPORTPATH package not found in listed packages: %s", toolexecImportPath) } tf.origImporter = importerForPkg(tf.curPkg) @@ -1544,7 +1544,7 @@ func computePkgCache(fsCache *cache.Cache, lpkg *listedPackage, pkg *types.Packa // cmd/bundle will include a go:generate directive in its output by default. // Ours specifies a version and doesn't assume bundle is in $PATH, so drop it. -//go:generate go run golang.org/x/tools/cmd/bundle -o cmdgo_quoted.go -prefix cmdgoQuoted cmd/internal/quoted +//go:generate go tool bundle -o cmdgo_quoted.go -prefix cmdgoQuoted cmd/internal/quoted //go:generate sed -i /go:generate/d cmdgo_quoted.go // computeLinkerVariableStrings iterates over the -ldflags arguments,