This page has been updated a long time ago. Information found here could be outdated and may lead to missconfiguration.
Some of the links and references may be broken or lead to non existing pages.
Please use this docs carefully. Most of the information here now is only for reference or example!
Compile GO language on Raspberry PI¶
There are many ways to install GO language, eg. you can compile from source or use the pre-compiled binaries. Here I want to show you how you can compile GO from source.
- Raspberry PI 2 or 3
I used this version:
Linux raspberrypi 4.4.13-v7+ #894 SMP Mon Jun 13 13:13:27 BST 2016 armv7l GNU/Linux
2016-05-27-raspbian-jessie.zipcan be downloaded from the official RPI page.
And you check these links:
2. Install from source using git¶
In order to install the latest
go you have to install 1.4.x version first.
I followed this useful link.
- create a dedicated user:
root@raspberrypi:~# useradd gcp
- I set the home dir to /opt/google-cloud-print
- Clone the repository from GIT:
git clone https://github.com/golang/go
- Rename and copy â€œgoâ€ directory for different versions:
Checkout the versions
First of all we will compile 1.4.3:
- When the compilation is successfully finished, you have to set some system environments:
- Next compile the newer versions. I move forward with 1.6.x:
You can run into "not enough" memory issue while package is being tested, but despite the errors
go will work properly.
If everything was fine you use different versions of GO, by exporting system environments. I created 3 files to manage different versions:
gcp@raspberrypi:~/git$ pwd /opt/google-cloud-print/git gcp@raspberrypi:~/git$ ls -al total 32 drwxr-xr-x 5 gcp gcp 4096 Aug 11 14:35 . drwxr-xr-x 4 gcp gcp 4096 Aug 11 11:55 .. drwxr-xr-x 12 gcp gcp 4096 Aug 11 10:49 go1.4.3 drwxr-xr-x 11 gcp gcp 4096 Aug 11 11:17 go1.5.2 drwxr-xr-x 11 gcp gcp 4096 Aug 11 13:57 go1.6.3 -rwxr-xr-x 1 gcp gcp 158 Aug 11 14:34 setGoEnv1.4.3.sh -rwxr-xr-x 1 gcp gcp 158 Aug 11 14:35 setGoEnv1.5.2.sh -rwxr-xr-x 1 gcp gcp 158 Aug 11 14:35 setGoEnv1.6.3.sh
Please keep in mind that you have to log out from the current shell after using one of the installed go, because the scripts Iâ€™m using to set the environment which will concatenate the PATH after each run. For example you set the sysenv to use 1.4.3, the script will add
/opt/google-cloud-print/git/go1.4.3/bin/ directory to the PATH env.
Or you have to remove the current go path from system
PATH before sourceing another environment.
3. Install from downloaded source¶
You can download source code form the offical web page: https://golang.org/dl/
As you can see there are precompiled binary file for ARM CPUs. But only for ARMv6! Be sure which type of CPU you are using before downloading GO. (Raspberry 2 has ARMv7 CPU!) The install steps are the same as in case of using GIT. Just for fun I will show you how easy to use these official source codes.
- Download the source code of version 1.4.3.
gcp@raspberrypi:~/sources$ wget https://storage.googleapis.com/golang/go1.4.3.src.tar.gz --2016-08-12 16:19:08-- https://storage.googleapis.com/golang/go1.4.3.src.tar.gz Resolving storage.googleapis.com (storage.googleapis.com)... 126.96.36.199, 2a00:1450:4001:817::2010 Connecting to storage.googleapis.com (storage.googleapis.com)|188.8.131.52|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 10875170 (10M) [application/octet-stream] Saving to: â€˜go1.4.3.src.tar.gz.1â€™ go1.4.3.src.tar.gz.1 100%[=======================================================================================================>] 10.37M 5.26MB/s in 2.0s 2016-08-12 16:19:10 (5.26 MB/s) - â€˜go1.4.3.src.tar.gz.1â€™ saved [10875170/10875170]
After the compilation is done you can compile later versions of
go. Don't forget to set system environments before compiling.