Reputation: 173
I want to compile my Go code in windows 10 for Linux (Ubuntu).
I use the commands:
SET GOOS=linux
SET GOARCH=amd64
go build .\main.go
but the compiler creates an .exe file.
How to cross-compile this code for linux?
Upvotes: 0
Views: 1244
Reputation: 4457
If you use PowerShell then you should use $Env:GOOS = "linux"; $Env:GOARCH = "amd64"; go build .\main.go
Upvotes: 7
Reputation:
Try this like a one line command in the terminal: GOOS=linux GOARCH=amd64 go build .\main.go
Upvotes: 0