- Raspberry Pi 3
- Host OS: Raspbian Jessie Lite image (downloaded 2016-09-23-raspbian-jessie-lite.zip from the official site)
The general idea is that you first download the source and then compile it. But, for your convenience and to bypass this procedure, this git repository has already a binary tar, named go1.4.3.linux-armv7.tar.gz
.
- If you want to learn how this file was generated, continue reading the relative section below ("go1.4.3.linux-armv7.tar.gz - how it was created").
- If you want to proceed with the installation, continue with the following commands.
rm -rf /usr/local/go
git clone https://github.com/tgogos/rpi_golang.git # (current repository)
cd rpi_golang/
tar -xzf go1.4.3.linux-armv7.tar.gz -C /usr/local
export PATH=/usr/local/go/bin:$PATH
echo "export PATH=/usr/local/go/bin:$PATH" >> /root/.bashrc
go version #test it works
rm -fr $HOME/go1.4
mkdir -p $HOME/go1.4
tar -xzf go1.4.3.linux-armv7.tar.gz -C $HOME/go1.4 --strip-components=1
rm -fr /usr/local/go
wget https://dl.google.com/go/go1.10.3.src.tar.gz
tar -xz -C /usr/local -f go1.10.3.src.tar.gz
cd /usr/local/go/src
time GOROOT_BOOTSTRAP=/root/go1.4 ./make.bash # See sample output below
go version # test that the new version is printed out
root@rpi:/usr/local/go/src# time GOROOT_BOOTSTRAP=/root/go1.4 ./make.bash
Building Go cmd/dist using /root/go1.4.
Building Go toolchain1 using /root/go1.4.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for linux/arm.
---
Installed Go for linux/arm in /usr/local/go
Installed commands in /usr/local/go/bin
real 8m42.421s
user 18m36.579s
sys 0m44.624s
root@rpi:/usr/local/go/src# go version
go version go1.10.3 linux/arm
The following information comes from this source: http://blog.hypriot.com/post/how-to-compile-go-on-arm/
wget https://storage.googleapis.com/golang/go1.4.3.src.tar.gz
rm -rf /usr/local/go
tar -xz -C /usr/local -f go1.4.3.src.tar.gz
cd /usr/local/go/src
time ./make.bash
tar -czf ~/go1.4.3.linux-armv7.tar.gz -C /usr/local go
tar --numeric-owner -czf ~/go1.4.3.linux-armv7.tar.gz -C /usr/local go
https://github.com/moovweb/gvm
sudo apt-get install curl git make binutils bison gcc build-essential
# install gvm
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source /home/pi/.gvm/scripts/gvm
# install go
gvm install go1.4
gvm use go1.4
export GOROOT_BOOTSTRAP=$GOROOT
gvm install go1.7
gvm use go1.7 --default
From the "Getting Started" page of golang.org:
Add
/usr/local/go/bin
to the PATH environment variable. You can do this by adding this line to your/etc/profile
(for a system-wide installation) or$HOME/.profile
:
export PATH=$PATH:/usr/local/go/bin
Most of the times that I have used a combination of Go and Beego framework, I add the following lines:
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
# and for the `bee` tool:
export PATH=$PATH:$GOPATH/bin