Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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"
Copy link

englianhu commented Aug 28, 2021

-fatal: not a git repository (or any of the parent directories): .git

Can you please post those error logs at

and also please include the output for go env ?


Copy link

angelgrozdanov commented Aug 29, 2021

Thanks @udhos! That script worked perfectly!

Copy link

ubbcou commented Sep 6, 2021

sudo ./


Copy link

PushanMaharjan commented Sep 9, 2021

Thank you @udhos for the script! works perfectly

Copy link

ianmcfall commented Sep 12, 2021

@udhos Thanks!!!

Copy link

ksrof commented Sep 19, 2021

@udhos Thanks mate!!

Copy link

rpiceage commented Sep 30, 2021

@udhos Thanks a lot :)

Copy link

kaefahtech commented Oct 5, 2021

Where are you getting version 1.8 from? The page only has up to version 1.17. The link above led me to version 1.17.

Copy link

dangolbeeker commented Oct 14, 2021

I have sketched a simple script to automate the task:

git clone
cd update-golang
sudo ./


Copy link

StrglrX commented Oct 22, 2021

thank's @Clanwarz-zz

Copy link

arnabsen1729 commented Oct 25, 2021

I have sketched a simple script to automate the task:

git clone
cd update-golang
sudo ./

Thanks, @udhos, I wasn't very sure to download a script and run it with sudo but still took the risk and it worked. It's amazing.

Copy link

pau-lo commented Nov 2, 2021

Copy link

onbit-uchenik commented Nov 20, 2021

@udhos Thanks a lot man !!!!

Copy link

ziauddin commented Nov 23, 2021

Thank you @udhos for your nice script

Copy link

demirkayaender commented Dec 31, 2021

Thanks for sharing! For some reason the instructions didn't work for me. I found this github repo to upgrade golang which worked like a charm: if anybody else has issues.

Copy link

czpmango commented Jan 4, 2022

@udhos Thanks for the script! It really helps a lot.

Copy link

xhujerr commented Jan 6, 2022

@fearphage : the release string needs a little update

release=$(curl --silent | grep -Eo 'go[0-9]+(\.[0-9]+)+' | sort -V | uniq | tail -1)

The page was permanently moved to

so the release var now should be:

release=$(curl --silent | grep -Eo 'go[0-9]+(\.[0-9]+)+' | sort -V | uniq | tail -1)

Otherwise thanks for the oneliner. Worked perfectly for me.

Copy link

kimlianlopez commented Mar 2, 2022

@udhos works like a charm! thanks :)

Copy link

mohdsiddique commented Mar 2, 2022

If you are on Mac then download the latest version .pkg file and click on it. It detects the old version and will replace the old with a new one.

Copy link

kls0e commented Mar 27, 2022


Copy link

lyb2333 commented Mar 28, 2022

very appreciated

Copy link

Meowzz95 commented Apr 6, 2022

The go team's email list gives another option:

If you have Go installed already, an easy way to try go1.18
is by using the go command:
$ go install
$ go1.18 download

Copy link

realamirhe commented Apr 8, 2022

If you want to config go in gitpod

rm -rf /home/gitpod/go && tar -C /home/gitpod/ -xzf go1.18.linux-amd64.tar.gz

Copy link

bichanna commented Apr 28, 2022


Copy link

Zireael07 commented May 7, 2022

@Meowzz95 thanks for the tip!

Copy link

nicmwe commented May 16, 2022

I have sketched a simple script to automate the task:

git clone
cd update-golang
sudo ./

Thanks @udhos !!

Copy link

m-cat commented May 25, 2022

This seems to work great, but for me on OSX, it wasn't getting picked up. I found out that I already had go installed from homebrew, which took precedence.

On OSX I recommend brew install go and brew upgrade go as the easiest way to go about this.

Copy link

cognivore commented Jun 13, 2022

Oh my. 😭

Copy link

abdennour commented Jun 13, 2022

Oh my zsh

Copy link

omarelsayed23 commented Jul 11, 2022

Thanks man! @udhos

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