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-goUbuntu
Using PPA
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
sudo apt install golang-goUsing snap
sudo snap install --classic goArch Linux
sudo pacman -Sy goNixOs
nix-shell -p goor system wide with,
/etc/nixos/configuration.nix
environment.systemPackages = [
pkgs.go
];Void Linux
sudo xbps-install -S goGeneric 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/.profileSource the changes
source $HOME/.profileStep 5 - verify the installation
go versionif this ouputs the current version, the installation was successful.
Last updated on