Open
Description
Go version
go version go1.24.1 darwin/arm64
Output of go env
in your module/workspace:
AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN='/Users/ianwahbe/go/bin'
GOCACHE='/Users/ianwahbe/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/ianwahbe/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/fg/_1q36r4j6yx0rwz2fbhjd5y40000gn/T/go-build3052038314=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/ianwahbe/go/src/github.com/example/empty/go.mod'
GOMODCACHE='/Users/ianwahbe/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/ianwahbe/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.24.1/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/ianwahbe/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.24.1/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.1'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
I was using go tool -n github.com/iwahbe/helpmakego
in my Makefile to work around #71733 like this:
HELPMAKEGO := $(shell go tool -n github.com/iwahbe/helpmakego)
# Use the tool as intended - details don't really matter here
$(shell ${HELPMAKEGO} ...)
I noticed that sometimes $(shell ${HELPMAKEGO} ...)
would fail unexpectedly, saying that there was no file at ${HELPMAKEGO}
.
I can replicate this behavior locally:
$ mkdir repro
$ go mod init
$ go get -tool github.com/iwahbe/helpmakego
$ go tool -n github.com/iwahbe/helpmakego | tee should_exist && rm $(cat should_exist)
/Users/ianwahbe/Library/Caches/go-build/c5/c503c5059f1c48a29b1dc68749074f475aaf82c717ef355e7079f7e9b4116c2b-d/helpmakego
$ go tool -n github.com/iwahbe/helpmakego | tee should_exist && rm $(cat should_exist)
/var/folders/fg/_1q36r4j6yx0rwz2fbhjd5y40000gn/T/go-build1160981703/b001/exe/helpmakego
rm: /var/folders/fg/_1q36r4j6yx0rwz2fbhjd5y40000gn/T/go-build1160981703/b001/exe/helpmakego: No such file or directory
$ go tool -n github.com/iwahbe/helpmakego | tee should_exist && rm $(cat should_exist)
/Users/ianwahbe/Library/Caches/go-build/c5/c503c5059f1c48a29b1dc68749074f475aaf82c717ef355e7079f7e9b4116c2b-d/helpmakego
$ go tool -n github.com/iwahbe/helpmakego | tee should_exist && rm $(cat should_exist)
/var/folders/fg/_1q36r4j6yx0rwz2fbhjd5y40000gn/T/go-build1221207145/b001/exe/helpmakego
rm: /var/folders/fg/_1q36r4j6yx0rwz2fbhjd5y40000gn/T/go-build1221207145/b001/exe/helpmakego: No such file or directory
You will see that every other time go tool -n github.com/iwahbe/helpmakego
it points to a file that doesn't exist.
What did you see happen?
$ go tool -n github.com/iwahbe/helpmakego
/var/folders/fg/_1q36r4j6yx0rwz2fbhjd5y40000gn/T/go-build1221207145/b001/exe/helpmakego
What did you expect to see?
I expect that any time go tool -n ...
is run, it will point to a runnable executable.
If that isn't true, then go help tool
should document what conditions are necessary to ensure that go tool -n ...
will point to an executable file.