There doesn't seem to be a definitive guide out there for quick reading on how to get Go installed and working on an embedded platform running Armbian, so I am putting this out there as a quick-reference for myself and others who might need to do this at some point.
My set up is:
First things first, grab the install tarball from the Go website. This one runs on Armbian (AllWinner H3 chip)
In your home directory, simply expand the archive:
$tar -xvf go1.8.3.linux-armv6l.tar.gz
The above operation will neatly untar everything for you and you can do an initial check- important since this is a non-x86 machine.
In your home directory (or where you untarred to) you can get to the golang executable via:
By running the executable on the command line we can do a quick check that we have a workable version:
Now we need to set Go up properly, so we need to move the files to the correct place.
$sudo mv go /usr/local
This will move the unpacked files to /usr/local. In theory you could install these anywhere but this is the most logical choice. Now that the Go installation lives in /usr/local we can set up the environment variables:
Three variables have to be set, namely GOROOT, GOPATH, and PATH. To do this and make sure it is available every time we work in Go, we will assume your workspace (workspace is where you want to write your code) is in your home directory somewhere i.e. home/[username]
Add the following to .profile:
Then, set a proper environment variable so that Go is accessible anywhere from the shell:
Open the environment variables file by editing it:
$sudo nano environment
At the end of the PATH= string, add the following:
Reboot the system to apply changes. Then in your home directory, create a simple Go program to test it.
Place the following in a file named test.go:
And then run that code using:
$go run test.go