Skip to content

Instantly share code, notes, and snippets.

@nikhita
Last active April 27, 2024 13:09
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"
@laurentknauss
Copy link

I switched to go1.21 version following your prompts , works great!

@dxps
Copy link

dxps commented Sep 1, 2023

Unfortunately, that go-up.sh solution doesn't cover some cases.

See a concrete example of how things can be destroyed:

…/apps ❯ curl -sL https://raw.githubusercontent.com/DieTime/go-up/master/go-up.sh | bash
❌ Go not installed, nothing to update
…/apps ❯ 
…/apps ❯ GOBIN=$(which go 2> /dev/null) && echo $GOBIN
…/apps ❯ 
…/apps ❯ tar zxf /disk2t/files/kits/dev/go/go1.21.0.linux-amd64.tar.gz 
…/apps took 1s❯ 
…/apps ❯ 
…/apps ❯ GOBIN=$(which go 2> /dev/null) && echo $GOBIN
/home/dxps/apps/go/bin/go
…/apps ❯ 
…/apps ❯ curl -sL https://raw.githubusercontent.com/DieTime/go-up/master/go-up.sh | bash
❌ Couldn't download and unpack go with version 1.21.0
time 2023-08-04T20:14:06Z
…/apps took 1s❯ 
…/apps ❯ ls -l go/
total 0
…/apps ❯

@Olanetsoft
Copy link

Thank you

@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

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