0
votes

I have a new MacBook with an m1 chip.

I want to make an windows executable file from a main.go file. Internally it uses couple of external libraries. I am able to build executable for m1 processor using the command go build main.go.

But when I try to build windows executable using command env GOOS=windows GOARCH=amd64 go build main.go, it fails with build constraints exclude all Go files

dilipyadav@Dilips-MacBook-Pro-2 isengard % pwd
/Users/dilipyadav/githome/my-project/cmd/isengard
dilipyadav@Dilips-MacBook-Pro-2 isengard % ls
main.go
dilipyadav@Dilips-MacBook-Pro-2 isengard % env GOOS=windows GOARCH=amd64 go build main.go
package command-line-arguments
    imports fyne.io/fyne/v2/app
    imports fyne.io/fyne/v2/internal/driver/glfw
    imports fyne.io/fyne/v2/internal/painter/gl
    imports github.com/go-gl/gl/v3.2-core/gl: build constraints exclude all Go files in /Users/dilipyadav/go/pkg/mod/github.com/go-gl/[email protected]/v3.2-core/gl
package command-line-arguments
    imports github.com/gordonklaus/portaudio: build constraints exclude all Go files in /Users/dilipyadav/go/pkg/mod/github.com/gordonklaus/[email protected]
dilipyadav@Dilips-MacBook-Pro-2 isengard %

I am following the build document from here

For the error build constraints exclude all Go files, I checked build constraints exclude all Go files in.

Any help is highly appreciated.

1

1 Answers

3
votes

run this inside your project main folder (where main.go exists)

GOOS=windows GOARCH=amd64 go build -o output_name.exe