Monday, February 24, 2014

Updating Go (GoLang) From Source

I previously posted an article explaining how to install Go on a Raspberry Pi with cross-platform support. If you're like me (and depending on the platform), you're probably used to installing programs through packages, app stores, or single-file MSI installers or setup executables. Or on Linux platforms like Raspbian you first turn to the repos used by apt. Don't feel bad. These methods were invented to prevent DLL Hell, bit rot, or dependency problems. Sometimes they make the chore of keeping your system up to date a little easier.

The method I used was the tried-and-true UNIX way of doing things..."Compile From Source," sometimes referred to as the "Dammit Why Won't This Work" method. I have to admit, though, Go actually worked pretty well, meaning the maintainers of the code base are doing a really find job at taking care of their stuff.

But what if you want to update to the latest version? The version I installed in the post was a development version, meaning that as the devs are updating the code base with latest features and fixes, that was what was getting compiled on my Pi.

But what if I wanted to update? Or use the official stable release version, which is the version that is more or less tested to be...well, feature stable?

Turns out it wasn't that hard to get up to date.

First, I run screen. Mainly because I'm SSH'd into the Raspberry Pi, and since the steps can take awhile, if something disconnects me I don't want the process to be interrupted. Then I start the process thus:

cd go/src
hg pull
hg update release
./all.bash

This step took awhile as the Raspberry Pi worked on compiling the Go source.

Now for the cross-compile tools.

source golang-crosscompile/crosscompile.bash
go-crosscompile-build-all

This step will take longer than the initial compile. That's why I used screen...I can use Ctrl-a/d to detach from my session and check the progress later. 

Once the compiles are all finished, though, you should be able to

go version

...and have the prompt reply with:

go version go1.2 linux/arm

No comments:

Post a Comment