fork/exec C:\Users\user1\AppData\Local\Temp\go-build1624998878\b001\exe\main.exe: This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.
This error is thrown whenever I try to run any go files.
I have tested with a simple "hello world" app:
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello World")
}
and tried various ways of building this (none of which work):
go run main.go
go build main.go
go build -o hello main.go
I already tried:
- excluding the go files and the work directory from windows defender and antivirus.
- reinstalling Go and Go extension from the vscode.
- Unsetting all Go env vars
- Running the same program with same env vars on another system (successful).
I checked the TEMP directory for the files and it does create new go-build12xxx everytime I run or build. But throws this error. I've already tried both x86 (32-bit) or x64 (64-bit) version of Go though the OS is 64-bit Windows 10. The Go version is go1.21.1.windows-amd64.msi.
What could be the cause and solution of this?
go env:
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\user1\AppData\Local\go-build
set GOENV=C:\Users\user1\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\user1\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\user1\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.1
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=D:\Inter\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\user1\AppData\Local\Temp\go-build1803464262=/tmp/go-build -gno-record-gcc-switches```
file ./main.exeIt returns something like this:./main.exe: PE32+ executable (console) Aarch64, for MS Windowscheck whether Aarch64 is compatible with your system.go envand check the value of GOARCH & GOOS.For x86_64 device the value of GOARCH should be amd64 not arm64. To find the list of possible platforms:go tool dist listwhich returns: