I can confirm that what you are trying to achieve works for me on Windows 7 and Windows 10 with go 1.10.2. To check that your go install supports your desired target, run this command:
go tool dist list | find "linux/amd64"
You should make sure that you set the environment variables without any additional or hidden spaces, set them this way:
set GOOS=linux set GOARCH=amd64
Then verify, for example this way:
echo !%GOOS%! echo !%GOARCH%!
If the combination is not valid, you should get this message:
cmd/go: unsupported GOOS/GOARCH pair linux /amd64
After this run your build:
go build -v -x -o foreign_linux foreign.go
Following Volkers advice you can check if the created binary really is a linux binary:
You will receive some cryptic characters, but at the beginning of the first line should be
ELF. If it is an exe, you will see