

Cross compilation just got better in Go 1.5 - mholt
http://dave.cheney.net/2015/03/03/cross-compilation-just-got-a-whole-lot-better-in-go-1-5

======
frikk
I had a recent project that I built with go 1.3. It was a small project ( < 4
weeks ) but it had some interesting requirements -- my app had to be deployed
to ARM (raspi), and on an OSX laptop for control, and I use a linux laptop.

The cool part was that it "just worked".

    
    
       GOARCH=arm go build myapp.go
       GOOS=darwin go build myapp.go
       go build myapp.go
    

All three "just worked" with absolutely no surprises, including use of the
http engine, json, and a third party serial port library. The native binaries
run like a champ.

Looking forward to the continued evolution of golang.

~~~
yoklov
> All three "just worked" with absolutely no surprises

Jeez. That's pretty incredible. As someone who absolutely hates dealing with
build configuration it's almost tempting enough to take a closer look at go,
despite the fact it's garbage collected and I'd never be able to use it (or,
if we're being completely honest, want to).

~~~
LBarret
Go tooling is excellent. Above anything else IMHO. Sadly the language itself
is not so good.

~~~
nothrabannosir
This is completely true. "Everything about Go is amazing, except the
language."

No snark intended, I say this unironically as someone who uses Go regularly,
even for new projects.

~~~
bkeroack
The language is pretty polarizing--you either "get" and appreciate the design
decisions or you find them limiting and archaic.

~~~
nothrabannosir
They are the people you hear from. A lot of people are neutral. People who get
it, but don't care either way. They don't write opinionated blog posts every
Sunday to lament or idolize the newest feature in Go.

------
mholt
This is awesome.

Back in the day, writing cross-platform code meant knowing the ins-and-outs of
each platform you wanted to support and coding specifically for each one.
Interpreted languages (like Python) and runtimes (like JRE) take a lot of the
pain away, but that means all those programs have a dependency: the
interpreter or runtime.

Go isn't interpreted and bundles its runtime inside the executable. That has
always been pretty great, but with Go 1.5, the programmer won't even have to
run `env GOOS=... GOARCH=... make.bash --no-clean` before compiling for
another platform.

With veteran OS and systems engineers working on the language, this is why we
can have nice things.

~~~
pjmlp
> Back in the day, writing cross-platform code meant knowing the ins-and-outs
> of each platform you wanted to support and coding specifically for each one.

If you mean C and C++ POSIX behavior, yes.

If you mean native languages with rich runtimes like Ada and Modula-2, not
really.

Finally Go doesn't get rid of OS specific stuff like pathnames, security, ...

------
bsaul
I'm really looking forward to see more tools ported to go. The simplicity of
copy/paste deployment is really something you don't realize until you've
experienced it.

Now, the simple idea of installing python and dependencies then doing pip
install for wal-e installation, made me search for an hour on git in hope for
a standalone golang binary.

~~~
mamcx
That is the same experience with Delphi.

Is weird is not more popular (not just Delphi/pascal, but the idea of easy
copy/paste deployment)...

~~~
girvo
One could make an argument that with PHP, copy-paste deployment _is_ popular.
Of course, it's not quite the same thing, as you'll need Apache/etc. setup,
however that is one of PHP's strengths. It's good to see another language
doing something similar, but in a nicer, far more performant way: specifically
for web development, the way Go does stuff is brilliant in my opinion.

------
samuell
Awesome stuff! :)

In case someone wants to try out this cleanly in a docker or virtualbox
without breaking their host machine's golang install, it is now available as a
commented-out ansible role in the vagrant box I created over the weekend:

[https://github.com/samuell/golang-vagrant-
ansible](https://github.com/samuell/golang-vagrant-ansible)

(Instructions for enabling the Go 1.5 role in the repo README ... but in
short, just uncomment "\- golang-1.5" in playbook.yml, and comment out "\-
golang" instead, before running "vagrant up docker" or "vagrant up
virtualbox").

------
TylerE
I've been away from go for a long while.

Did they ever figure out dependency versioning?

~~~
cyri
They've started to think about it:
[https://groups.google.com/forum/#!topic/golang-
dev/nMWoEAG55...](https://groups.google.com/forum/#!topic/golang-
dev/nMWoEAG55v8)

------
vezzy-fnord
Unsurprisingly they've taken the Plan 9 approach, sardonically contrasted with
the GNU one here: [http://aiju.de/rant/cross-
compiling](http://aiju.de/rant/cross-compiling)

------
MereInterest
I haven't checked in a while. Does cross-compiling now support libraries that
are implemented in C? As this includes some of the standard library, this
seems like a rather large stumbling block.

------
giovannibajo1
Does it work if I first compile for GOARM=5 and then for GOARM=7 (or vice
versa)?

