Reputation: 8944
I am into a situation in which I have to run a Go build on macOS/OS X. The build will be generated from the Linux operating system, and that build I have to run on macOS/OS X.
I have tried to generate a cross-platform build for Mac using the below command and build is generated.
env GOOS=linux GOARCH=amd64 go build
This generated a Go build but I move this build to Mac it shows .dms file extension.
Now I have two questions:
Upvotes: 13
Views: 29022
Reputation: 3273
Since your binary will target OS X, you need to set GOOS
to darwin
, so your command will be:
env GOOS=darwin GOARCH=amd64 go build
Documentation on compiler environment variables is in Optional environment variables.
To run the binary on Mac, you need to make sure that binary is executable:
chmod +x path-to-binary
And then run it in Terminal:
path-to-binary
Upvotes: 30