mohammad ghari
mohammad ghari

Reputation: 173

I Can not use Cross Compiler

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

Answers (2)

Vitaly Migunov
Vitaly Migunov

Reputation: 4457

If you use PowerShell then you should use $Env:GOOS = "linux"; $Env:GOARCH = "amd64"; go build .\main.go

Upvotes: 7

user5715068
user5715068

Reputation:

Try this like a one line command in the terminal: GOOS=linux GOARCH=amd64 go build .\main.go

Upvotes: 0

Related Questions