[GOLANG] update golang - fourslickz/notes GitHub Wiki
To update Go on Ubuntu, you can follow these specific steps:
1. Check the Current Version of Go
Check your current Go version to confirm if an update is necessary:
bash
go version
2. Remove the Existing Go Installation
If you installed Go from a package or manually in /usr/local, remove it:
bash
sudo rm -rf /usr/local/go
3. Download the Latest Version of Go
Visit Go's download page and find the latest version link for Linux (.tar.gz file). Alternatively, you can download it using wget. Replace go1.X.X with the latest version (e.g., go1.20.5):
bash
wget https://go.dev/dl/go1.X.X.linux-amd64.tar.gz
4. Extract the Archive to /usr/local
After downloading, extract the archive to /usr/local, which is the standard location for Go:
bash
sudo tar -C /usr/local -xzf go1.X.X.linux-amd64.tar.gz
5. Update the PATH Environment Variable
If Go’s bin directory is not in your PATH, add it by updating your shell profile (e.g., ~/.profile, ~/.bashrc, or ~/.zshrc):
bash
echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile
Reload the profile to apply the changes:
bash
source ~/.profile
6. Verify the Installation
Check the Go version to confirm the update was successful:
bash
go version
7. Clean Up (Optional)
Remove the downloaded .tar.gz file:
bash
rm go1.X.X.linux-amd64.tar.gz
Your Go installation should now be updated to the latest version on Ubuntu.