Skip to content

Instantly share code, notes, and snippets.

@simoncos
Forked from konradko/golang_on_rpi.md
Last active March 30, 2024 17:56
Show Gist options
  • Save simoncos/49463a8b781d63b5fb8a3b666e566bb5 to your computer and use it in GitHub Desktop.
Save simoncos/49463a8b781d63b5fb8a3b666e566bb5 to your computer and use it in GitHub Desktop.
Install Golang 1.9 on Raspberry Pi

Install Golang 1.9:

wget https://storage.googleapis.com/golang/go1.9.linux-armv6l.tar.gz
sudo tar -C /usr/local -xzf go1.9.linux-armv6l.tar.gz
export PATH=$PATH:/usr/local/go/bin # put into ~/.profile

If already installed old golang with apt-get:

sudo apt remove golang
sudo apt-get autoremove
source .profile

Test:

go version
@jt3k
Copy link

jt3k commented Sep 1, 2020

Current corrected version of the script

url='https://golang.org'$(curl https://golang.org/dl/ | grep armv6l | sort --version-sort | tail -1 | grep -o -E "/dl/go[0-9]+\.[0-9]+((\.[0-9]+)?).linux-armv6l.tar.gz")
archive_name=$(echo ${url} | cut -d '/' -f5)
wget ${url}
sudo tar -C /usr/local -xvf ${archive_name}
cat >> ~/.bashrc << 'EOF'
export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
EOF
rm ${archive_name}
source ~/.bashrc

@rainthstrive
Copy link

Current corrected version of the script

url='https://golang.org'$(curl https://golang.org/dl/ | grep armv6l | sort --version-sort | tail -1 | grep -o -E "/dl/go[0-9]+\.[0-9]+((\.[0-9]+)?).linux-armv6l.tar.gz")
archive_name=$(echo ${url} | cut -d '/' -f5)
wget ${url}
sudo tar -C /usr/local -xvf ${archive_name}
cat >> ~/.bashrc << 'EOF'
export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
EOF
rm ${archive_name}
source ~/.bashrc

Just did it on my Pi 4 and it worked perfectly. Thanks.

@guizzardi
Copy link

Current corrected version of the script

url='https://golang.org'$(curl https://golang.org/dl/ | grep armv6l | sort --version-sort | tail -1 | grep -o -E "/dl/go[0-9]+\.[0-9]+((\.[0-9]+)?).linux-armv6l.tar.gz")
archive_name=$(echo ${url} | cut -d '/' -f5)
wget ${url}
sudo tar -C /usr/local -xvf ${archive_name}
cat >> ~/.bashrc << 'EOF'
export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin
EOF
rm ${archive_name}
source ~/.bashrc

... works on Pi Zero too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment