Install Golang on Debian/Ubuntu/Arch/Void/NixOs/Generic Linux Distros
Debian
works for buster/bullseye/bullseye-backports/bookworm/bookworm-backports/trixie/sid
sudo apt install golang-go
Ubuntu
Using PPA
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
sudo apt install golang-go
Using snap
sudo snap install --classic go
Arch Linux
sudo pacman -Sy go
NixOs
nix-shell -p go
or system wide with,
/etc/nixos/configuration.nix
environment.systemPackages = [
pkgs.go
];
Void Linux
sudo xbps-install -S go
Generic Linux Distros
Step 1 - Download Golang
Download the latest version of Go from the official site.
Step 2 - Remove any previous Go installation
rm -rf /usr/local/go
ℹ️
(You may need to run the command as root or through sudo).
Step 3 - Extract downloaded go files
tar -C /usr/local -xzf go1.22.5.linux-amd64.tar.gz
ℹ️
Change the file name according to the current version.
⚠️
Do not untar the archive into an existing /usr/local/go tree. This might produce broken Go installs.
Step 4 - Extract downloaded go files
Add /usr/local/go/bin to the PATH environment variable in your $HOME/.profile or /etc/profile
echo 'export PATH=$PATH:/usr/local/go/bin' >> $HOME/.profile
Source the changes
source $HOME/.profile
Step 5 - verify the installation
go version
if this ouputs the current version, the installation was successful.
Last updated on