Installing Go on Linux
Go (or golang) is a multi-purpose programming language that was originally developed by Google. See go.dev for details.
- Download the latest version of the Go development environment from https://go.dev/dl/ to
~/Downloads. Alternatively, callwgetin that folder: ```shellVerify the version!
wget https://go.dev/dl/go1.25.7.linux-arm64.tar.gz ``
- Delete the symbolic link
/opt/go(if it exists), then extract the archive you just downloaded into/opt, creating a fresh Go tree in/opt/go:sudo rm /opt/go && sudo tar -C /opt -xzvf ~/Downloads/go*.tar.gzDo not untar the archive into an existing
/opt/gotree! This is known to produce broken Go installations. - Rename
/opt/goto/opt/go1.25.7or whatever the current version of the software is.sudo mv /opt/go /opt/go1.25.7 - Create a symbolic link for the new folder:
sudo ln -s /opt/go1.25.7 /opt/go - Add the environment variables for Go to
$HOME/.bashrc:# Go Environment Settings export GOROOT=/opt/go export GOPATH=$HOME/go export PATH=$PATH:$GOROOT/bin:$GOPATH/binNote: Changes made to a profile file may not apply until the next time you log into your computer. To apply the changes immediately, just run the shell commands directly or execute them from the profile using a command such as
source $HOME/.bashrc.Alternatively, the environment can be placed into
/etc/profile, to make them system-wide available. - Verify that you’ve installed Go by opening a command prompt and typing the following command:
go versionConfirm that the command prints the installed version of Go.