Skip to content

Instantly share code, notes, and snippets.

@nikhita
Last active April 7, 2025 21:32
Show Gist options
  • Save nikhita/432436d570b89cab172dcf2894465753 to your computer and use it in GitHub Desktop.
Save nikhita/432436d570b89cab172dcf2894465753 to your computer and use it in GitHub Desktop.
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

$ sudo rm -rf /usr/local/go

2. Install the new version

Go to the downloads page and download the binary release suitable for your system.

3. Extract the archive file

To extract the archive file:

$ sudo tar -C /usr/local -xzf /home/nikhita/Downloads/go1.8.1.linux-amd64.tar.gz

4. Make sure that your PATH contains /usr/local/go/bin

$ echo $PATH | grep "/usr/local/go/bin"
@SahilDhingraa
Copy link

windows update?

@dxps
Copy link

dxps commented Nov 2, 2023

@SahilDhingraa Plenty of options to consider. As an example, check this out.

@Tuanm
Copy link

Tuanm commented Nov 25, 2023

I have sketched a simple script to automate the task:

git clone https://github.com/udhos/update-golang
cd update-golang
sudo ./update-golang.sh

Thanks, bro!

@cryptopunkstar
Copy link

Thank you I practice V2 Sei Network on Ubuntu !!

@renanbastos93
Copy link

I have sketched a simple script to automate the task:

git clone https://github.com/udhos/update-golang
cd update-golang
sudo ./update-golang.sh

Thanks @udhos !!

🔝 thanks a lot

@herloncosta
Copy link

I have sketched a simple script to automate the task:

git clone https://github.com/udhos/update-golang
cd update-golang
sudo ./update-golang.sh

Great work man!

Very good solution, thanks!!

@HassanAarzoo
Copy link

You can also try brew upgrade go if you have installed go via brew

@renanbastos93
Copy link

Of course @HassanAarzoo but the problem to updated using raspibian.

@pask01
Copy link

pask01 commented May 21, 2024

Worked fine, thanks! I also had to remove old versions of Go from /usr/lib and /usr/share

$ rm -rf /usr/lib/go
$ rm -rf /usr/lib/go-1.13

$ rm -rf /usr/share/go
$ rm -rf /usr/share/go-1.13

@okedialf
Copy link

I have sketched a simple script to automate the task:

git clone https://github.com/udhos/update-golang
cd update-golang
sudo ./update-golang.sh

Great work man!

Awesome

@okedialf
Copy link

Thank you @Tuanm

@Tuanm
Copy link

Tuanm commented May 27, 2024

Thank you @Tuanm

What did you thank me for, bro? :'v

@CollinsWanjau
Copy link

After installing the latest go-system-wide, i get this version colloso@colloso-ThinkCentre-M73:~/Documents/Go/hello$ go version go version go1.20.3 linux/amd64

@catgoose
Copy link

catgoose commented Jul 6, 2024

Thank you @Tuanm

What did you thank me for, bro? :'v

Thanks chief

@michalis-papamichael
Copy link

Thanks

@pa035
Copy link

pa035 commented Sep 10, 2024

I have sketched a simple script to automate the task:

git clone https://github.com/udhos/update-golang
cd update-golang
sudo ./update-golang.sh

Worked for me. Any script that automatically cleans and removes the temporary files used for the installation?

@GuilhermeBn198
Copy link

guys, i've combined your implementations and gave it a little plus:

#!/usr/bin/env bash

version=$(go version 2>/dev/null || echo "none")
release=$(wget -qO- "https://golang.org/VERSION?m=text" | awk '/^go/{print $0}')

if [[ $version == *"$release"* ]]; then
    echo "The local Go version ${release} is up-to-date."
    exit 0
else
    echo "The local Go version is ${version}. A new release ${release} is available."
fi

release_file="${release}.linux-amd64.tar.gz"

tmp=$(mktemp -d)
cd $tmp || exit 1

echo "Downloading https://go.dev/dl/$release_file ..."
curl -OL https://go.dev/dl/$release_file

sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf $release_file

rm -rf $tmp

cd ~

export GOROOT=/usr/local/go
export PATH=$GOROOT/bin:$PATH

version=$(go version)
if [[ $version == *"$release"* ]]; then
    echo "Now, local Go version is $version"
else
    echo "Failed to update Go. Current version is still $version."
    exit 1
fi

@marcelloinfoweb
Copy link

marcelloinfoweb commented Sep 22, 2024

Modified for ARM64 versions

#!/usr/bin/env bash

version=$(go version 2>/dev/null || echo "none")
release=$(wget -qO- "https://golang.org/VERSION?m=text" | awk '/^go/{print $0}')

if [[ $version == *"$release"* ]]; then
    echo "The local Go version ${release} is up-to-date."
    exit 0
else
    echo "The local Go version is ${version}. A new release ${release} is available."
fi

release_file="${release}.linux-arm64.tar.gz"

tmp=$(mktemp -d)
cd $tmp || exit 1

echo "Downloading https://go.dev/dl/$release_file ..."
curl -OL https://go.dev/dl/$release_file

sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf $release_file

rm -rf $tmp

cd ~

export PATH=$PATH:/usr/local/go/bin:$PATH

version=$(go version)
if [[ $version == *"$release"* ]]; then
    echo "Now, local Go version is $version"
else
    echo "Failed to update Go. Current version is still $version."
    exit 1
fi

@wathika-eng
Copy link

@draco1725
Copy link

@wathika-eng

Thanks bro, well scripted and it helped me great work

@dxps
Copy link

dxps commented Mar 6, 2025

@wathika-eng Thanks for the ref! 🙏 Indeed, it works like a charm!

Previously, I had Go 1.24 manually installed (extracted, to be precise) in $HOME/apps/go.

The script (wget https://git.io/go-installer.sh && bash go-installer.sh) discovered that
and just ask my confirmation to update it. And that's it! 🥰

@lib4u
Copy link

lib4u commented Mar 18, 2025

https://github.com/lib4u/goinstall
i just make shell script for linux
this can update go to latest version

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