Force go build arm64 on m1 mac

Currently running below command to build on my m1 mac, but it builds as amd64. I would like to build as arm64. I tried prepending the command with GOARCH=arm64, but then I get the error “package archwayhq/keyring-go/src/go: build constraints exclude all Go files in /Users/davidchoi/Work/philabs/node-api/hello-world/src/go” even though my main.go file does not use // go:build. Not sure what is happening.

go build -trimpath -buildmode=c-shared -ldflags '-w -s -extldflags "-lresolv"' -o ./src/go

On macs this is the command that is needed
CGO_ENABLED=1 GOARCH=arm64 GOHOSTARCH=arm64 go build -trimpath -buildmode=c-shared -ldflags '-w -s -extldflags "-lresolv"' -o -a ./src/go

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.