[talk] Golang and Platform Independence

Brian Cully bcully at gmail.com
Sun Dec 17 07:28:22 EST 2017


On December 17, 2017 at 00:55:32, Sujit K M (kmsujit at gmail.com) wrote:
> Golang does allow you to build executable. But it allows you to
> run the go program as an script. Below some of the commands
> that can be used in a document I had refered. What I found was
> that go can generate code on other platforms. So is my assumption
> correct it can run on platforms that don't support the go program as such.

	Go does this by installing its own source code and cross-compiling
it[1], so there’s no difference between it and, say, GCC, which can
also cross-compile. Or perl, which supports a tremendous number of
platforms. There’s really nothing special about it. You still need
compiler support for the target platform.

	FWIW, this has been baked into the Go distribution for some time — no
need for compiling from source any more.

-bjc

[1] I’m not sure why it needs to have its own source code around for
this. I can only assume it’s some kind of space-saving measure so you
don’t install a bunch of intermediate files for platforms you’re never
going to compile for, and instead it builds them only when needed at
least once. As with many decisions by Go, it’s an odd one; it’s not
like there aren’t other ways of accommodating that goal that have been
tried and used successfully for decades which work better.




More information about the talk mailing list