New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: get ignores GOARCH environment variable #36022
Comments
@dh1tw I believe that when you are specifying For example, on my amd64 linux install, if I specify a GOARCH of 386:
Can you check |
Hi @toothrot, The problem is actually easy to reproduce. For example, let's use a clean golang container: $ docker run -it golang:1.13-buster /bin/bash Within the container, we execute: $ export GOARCH=386
$ GOOS=linux GOOARCH=amd64 go get github.com/gogo/protobuf/protoc-gen-gofast
$ ls -al /go/bin
linux_386
$ ls -al /go/bin/linux_386
protoc-gen-gofast
$ file /go/bin/linux_386/protoc-gen-gofast
/go/bin/linux_386/protoc-gen-gofast: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, Go BuildID=WMKXHIKIYum37lDtIAnS/TsmmTc2G8ppJZvlNqQea/RbWhcsXqhRnKMWQcf3DW/UXNXxoQYDBTuNAoKMvWp, not stripped Despite explicitly specifying |
@dh1tw In your example here, |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?What did you do?
I want to cross compile a program to
GOOS=windows
andGOARCH=386
. These variables have already been set in the environment (see above). However, I want to install some tools (code generators) before actually (cross) compiling.Since the HostOS and HostARCH differ, I inline
GOOS
andGOARCH
before the actualgo get
:What did you expect to see?
I expect that by specifying
GOOS
andGOARCH
inline with thego get
command, that the program (in this caseprotoc-gen-gofast
) is compiled forlinux
amd64
.What did you see instead?
The inline
GOARCH
environment variable is ingnored. Instead a binary is produced for linux_386.The text was updated successfully, but these errors were encountered: