Go version
go version go1.24.6 linux/amd64
Output of go env
in your module/workspace:
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1243553581=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.6'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
When running on an AMD64 (x86) machine, running:
$ go install gitlab.com/tanna.dev/dependabot-graph@latest
$ ls -al /go/bin
-rwxr-xr-x 1 root root 8736189 Aug 12 18:41 dependabot-graph
Then, if we attempt to go install
when cross-compiling:
$ env GOOS=linux GOARCH=arm64 go install gitlab.com/tanna.dev/dependabot-graph@latest
$ ls /go/bin/* -al
-rwxr-xr-x 1 root root 8736189 Aug 12 18:41 /go/bin/dependabot-graph
/go/bin/linux_arm64:
total 7988
drwxr-xr-x 2 root root 4096 Aug 12 18:43 .
drwxrwxrwt 1 root root 4096 Aug 12 18:43 ..
-rwxr-xr-x 1 root root 8170425 Aug 12 18:43 dependabot-graph
What did you see happen?
When specifying a custom GOOS
and GOARCH
, the installed binary (dependabot-graph
) is installed to a different path, /go/bin/linux_arm64/dependabot-graph
What did you expect to see?
When specifying a custom GOOS
and GOARCH
, the installed binary (dependabot-graph
) is installed to the same path when not specifying a custom GOOS
and GOARCH
, /go/bin/dependabot-graph
Comment From: seankhliao
seems we may be missing some documentation, but this is working as intended.
see also #57485
Comment From: gabyhelp
Related Issues
- cmd/go: locating GOROOT fails when the `go` command is run from the cross-compiled `bin` subdirectory #62119 (closed)
- cmd/go: misleading warning on GOROOT == GOPATH in module mode #47889 (closed)
- go install with cross-compile fails with a permissions error #14213 (closed)
- cmd/dist: tools built with `GOROOT_FINAL` cannot locate it when copied to another location #61921 (closed)
- cmd/go: get ignores GOARCH environment variable #36022 (closed)
- cmd/go: go build inconsistent directory structure #11001 (closed)
- cmd/go: allow to install cross-compiled binaries when GOBIN is set #57485
- I want GOPATH==GOROOT effect without creating extra directory #69810 (closed)
- cmd/go: installs cmd/... in $GOBIN now #32674 (closed)
Related Discussions
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)