Haruka Saho's blog post "[[Windows] How to tell if the exe is x64 or x86 Part2](http://h-sao.com/blog/2020/11/07/how-to-check" -x64-or-x86-windows-binary-part2 /) "was checked with Go.
Go can be cross-compiled. I was able to confirm it in about 20 minutes from the tweet posted on the blog article.
$ cat main64.go
package main
import (
"fmt"
)
func main() {
fmt.Println("GOOS=windows GOARCH=amd64")
}
$ cat main32.go
package main
import (
"fmt"
)
func main() {
fmt.Println("GOOS=windows GOARCH=386")
}
$ GOOS=windows GOARCH=amd64 go build -o main64.exe main64.go
$ GOOS=windows GOARCH=386 go build -o main32.exe main32.go
$ ls main*
main32.exe main32.go main64.exe main64.go
$ file main32.exe
main32.exe: PE32 executable (console) Intel 80386 (stripped to external PDB), for MS Windows
$ file main64.exe
main64.exe: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows
You did it! q @ w @ p
Recommended Posts