How to uninstall Go?

Go

Go Problem Overview


I tried the answer here https://stackoverflow.com/questions/35643576/removed-golang-but-go-command-still-works, but it didn't work (I can still run go)

Currently, when I run which go I see this output

/usr/local/go/bin/go

I think I had two installations of go as my GOPATH was pointing to another folder named gocode. I've now removed that folder, and the usr/local/go/bin/go folder.

I've also removed my GOPATH. However, I can still run go.

How do I uninstall go?

Go Solutions


Solution 1 - Go

Update August 2019

Found the official uninstall docs worked as expected (on Mac OSX).

$ which go
/usr/local/go/bin/go

In summary, to uninstall:

$ sudo rm -rf /usr/local/go
$ sudo rm /etc/paths.d/go

Then, did a fresh install with homebrew using brew install go. Now, i have:

 $ which go
/usr/local/bin/go

Solution 2 - Go

You might try

rm -rvf /usr/local/go/

then remove any mention of go in e.g. your ~/.bashrc; then you need at least to logout and login.

However, be careful when doing that. You might break your system badly if something is wrong.

PS. I am assuming a Linux or POSIX system.

Solution 3 - Go

I'm using Ubuntu. I spent a whole morning fixing this, tried all different solutions, when I type go version, it's still there, really annoying... Finally this worked for me, hope this will help!

sudo apt-get remove golang-go
sudo apt-get remove --auto-remove golang-go

Solution 4 - Go

On a Mac-OS system

  1. If you have used an installer, you can uninstall golang by using the same installer.
  2. If you have installed from source
    rm -rf /usr/local/go
    rm -rf $(echo $GOPATH)
    

Then, remove all entries related to go i.e. GOROOT, GOPATH from ~/.bash_profile and run

source ~/.bash_profile

On a Linux system

rm -rf /usr/local/go
rm -rf $(echo $GOPATH)

Then, remove all entries related to go i.e. GOROOT, GOPATH from ~/.bashrc and run

source ~/.bashrc

Solution 5 - Go

For Windows 10:

  1. Go to Apps in the Settings App.
  2. Look for Go Programming Language * in the list and uninstall it.
  3. Remove C:\Go\bin from your PATH environment variable (only if you don't plan on installing another version of golang)

Solution 6 - Go

From the official install page -

> To remove an existing Go installation from your system delete the go > directory. This is usually /usr/local/go under Linux, macOS, and > FreeBSD or c:\Go under Windows. > > You should also remove the Go bin directory from your PATH environment > variable. Under Linux and FreeBSD you should edit /etc/profile or > $HOME/.profile. If you installed Go with the macOS package then you > should remove the /etc/paths.d/go file. Windows users should read the > section about setting environment variables under Windows.

Solution 7 - Go

Use this command to uninstall Golang for Ubuntu.

This will remove just the golang-go package itself.

sudo apt-get remove golang-go

Uninstall golang-go and its dependencies:

sudo apt-get remove --auto-remove golang-go

Solution 8 - Go

sudo apt-get remove golang-go
sudo apt-get remove --auto-remove golang-go

This is perfect for Ubuntu 18.18

Solution 9 - Go

On a Mac-OS Catalina

  1. need to add sudo before rm -rf /usr/local/go sudo rm -rf /usr/local/go otherwise, we will run into permission denial.

  2. sudo vim ~/.profile or sudo ~/.bash_profile remove export PATH=$PATH:$GOPATH/BIN or anything related to go lang

  3. If you use Zsh shell, then you need to remove the above line to ~/.zshrc file.

Hope it helps you :)

Solution 10 - Go

I just have to answer here after reading such super-basic advice in the other answers.

For MacOS the default paths are:

  1. /user/bracicot/go (working dir)
  2. /usr/local/go (install dir)

When uninstalling remove both directories.
If you've installed manually obviously these directories may be in other places.

One script I came across installed to /usr/local/.go/ a hidden folder because of permissioning... this could trip you up.

In terminal check:

echo $GOPATH
echo $GOROOT
#and
go version

For me after deleting all go folders I was still getting a go version.

Digging through my system path echo $PATH

/Users/bracicot/google-cloud-sdk/bin:/usr/local/bin:

revealed some places to check for still-existing go files such as /usr/local/bin

> Another user mentioned: /etc/paths.d/go

You may also want to remove GOPATH and GOROOT environment variables.
Check .zshsrc and or .bash_profile.
Or you can unset GOPATH and unset GOROOT

Solution 11 - Go

To uninstall go on MacOS, do this: On the terminal type which go it will; return a path like this /usr/local/go/bin/go Go to the root folder of go which is /usr/local/go/ and type on the terminal rm -rf /usr/local/go/ . you may get permission denied depending on your system setup, so the command should be prefixed with sudo like this

sudo rm -rf /usr/local/go/

It will request for your password, just enter it.

Solution 12 - Go

On linux we can do like this to remove go completely:

rm -rf "/usr/local/.go/"
rm -rf "/usr/local/go/"

These two command remove go and hidden .go files. Now we also have to update entries in shell profile.

Open your basic file. Mostly I open like this sudo gedit ~/.bashrc and remove all go mentions.

You can also do by sed command in ubuntu

sed -i '/# GoLang/d' .bashrc
sed -i '/export GOROOT/d' .bashrc
sed -i '/:$GOROOT/d' .bashrc
sed -i '/export GOPATH/d' .bashrc
sed -i '/:$GOPATH/d' .bashrc

It will remove Golang from everywhere. Also run this after running these command

source ~/.bash_profile

Tested on linux 18.04 also. That's All.

Solution 13 - Go

In MacOS, you can just do it with brew:

brew uninstall go
brew install go
brew upgrade go

Solution 14 - Go

  1. Go to the directory

    cd /usr/local
    
  2. Remove it with super user privileges

    sudo rm -rf go
    

Solution 15 - Go

only tab
rm -rvf /usr/local/go/
not works well, but
sudo rm -rvf /usr/local/go/
do.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionpraks5432View Question on Stackoverflow
Solution 1 - GoarcseldonView Answer on Stackoverflow
Solution 2 - GoBasile StarynkevitchView Answer on Stackoverflow
Solution 3 - GoloukaswhoView Answer on Stackoverflow
Solution 4 - Gopratik singhView Answer on Stackoverflow
Solution 5 - GoJaco BriersView Answer on Stackoverflow
Solution 6 - GonoobView Answer on Stackoverflow
Solution 7 - GoAnshuView Answer on Stackoverflow
Solution 8 - GoabridView Answer on Stackoverflow
Solution 9 - Gohemant singhView Answer on Stackoverflow
Solution 10 - GoBen RacicotView Answer on Stackoverflow
Solution 11 - Goken4wardView Answer on Stackoverflow
Solution 12 - Goamku91View Answer on Stackoverflow
Solution 13 - GotimtikeView Answer on Stackoverflow
Solution 14 - Goharold ramosView Answer on Stackoverflow
Solution 15 - GoYan LiView Answer on Stackoverflow