Skip to content

Instantly share code, notes, and snippets.

Embed
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"
@englianhu
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 https://github.com/udhos/update-golang/issues

and also please include the output for go env ?

udhos/update-golang#29

@angelgrozdanov
Copy link

angelgrozdanov commented Aug 29, 2021

Thanks @udhos! That script worked perfectly!

@ubbcou
Copy link

ubbcou commented Sep 6, 2021

sudo ./update-golang.sh

Thanks

@PushanMaharjan
Copy link

PushanMaharjan commented Sep 9, 2021

Thank you @udhos for the script! works perfectly

@ianmcfall
Copy link

ianmcfall commented Sep 12, 2021

@udhos Thanks!!!

@ksrof
Copy link

ksrof commented Sep 19, 2021

@udhos Thanks mate!!

@rpiceage
Copy link

rpiceage commented Sep 30, 2021

@udhos Thanks a lot :)

@kaefahtech
Copy link

kaefahtech commented Oct 5, 2021

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

@dangolbeeker
Copy link

dangolbeeker commented Oct 14, 2021

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!!

@StrglrX
Copy link

StrglrX commented Oct 22, 2021

thank's @Clanwarz-zz

@arnabsen1729
Copy link

arnabsen1729 commented Oct 25, 2021

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, 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.

@pau-lo
Copy link

pau-lo commented Nov 2, 2021

@onbit-uchenik
Copy link

onbit-uchenik commented Nov 20, 2021

@udhos Thanks a lot man !!!!

@ziauddin
Copy link

ziauddin commented Nov 23, 2021

Thank you @udhos for your nice script

@demirkayaender
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: https://github.com/travis-ci/gimme if anybody else has issues.

@czpmango
Copy link

czpmango commented Jan 4, 2022

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

@xhujerr
Copy link

xhujerr commented Jan 6, 2022

@fearphage : the release string needs a little update

release=$(curl --silent https://golang.org/doc/devel/release.html | grep -Eo 'go[0-9]+(\.[0-9]+)+' | sort -V | uniq | tail -1)

The page https://golang.org/doc/devel/release.html was permanently moved to https://go.dev/doc/devel/release

so the release var now should be:

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

Otherwise thanks for the oneliner. Worked perfectly for me.

@kimlianlopez
Copy link

kimlianlopez commented Mar 2, 2022

@udhos works like a charm! thanks :)

@mohdsiddique
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.

@kls0e
Copy link

kls0e commented Mar 27, 2022

appreciated

@lyb2333
Copy link

lyb2333 commented Mar 28, 2022

very appreciated

@Meowzz95
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 golang.org/dl/go1.18@latest
$ go1.18 download

@realamirhe
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

@bichanna
Copy link

bichanna commented Apr 28, 2022

Thanks!

@Zireael07
Copy link

Zireael07 commented May 7, 2022

@Meowzz95 thanks for the tip!

@nicmwe
Copy link

nicmwe commented May 16, 2022

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 !!

@m-cat
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.

@cognivore
Copy link

cognivore commented Jun 13, 2022

Oh my. 😭

@abdennour
Copy link

abdennour commented Jun 13, 2022

Oh my zsh

@omarelsayed23
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