Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Go cross-compile on Ubuntu to a Windows executable?

Using Ubuntu, what steps should I take to compile Go source code into a Windows executable?

like image 932
Inuart Avatar asked Dec 09 '11 15:12

Inuart


People also ask

Does Go compile to an executable?

While the go run command is a useful shortcut for compiling and running a program when you're making frequent changes, it doesn't generate a binary executable.

Can go cross compile?

This is called cross-compiling, and it's easy to do with Go. Programs written in Go can easily be compiled for a wide variety of target operating systems such as Windows, macOS, and Linux by using the GOARCH and GOOS environmental variables.

How go code is compiled?

Go is a compiled language. This means we must run our source code files through a compiler, which reads source code and generates a binary, or executable, file that is used to run the program. Examples of other popular compiled languages include C, C++, and Swift.

Are Go binaries cross-platform?

One of Go's greatest features is that it can be used to build statically linked cross-platform binaries.


1 Answers

Building Windows Go programs on Linux

like image 182
peterSO Avatar answered Sep 30 '22 15:09

peterSO