I tried the answer here 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 golang?
This question is related to
go
On a Mac-OS system
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
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 orc:\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.
On a Mac-OS Catalina
need to add sudo before rm -rf /usr/local/go sudo rm -rf /usr/local/go otherwise, we will run into permission denial.
sudo vim ~/.profile or sudo ~/.bash_profile remove export PATH=$PATH:$GOPATH/BIN or anything related to go lang
Hope it helps you :)
For Windows 10:
Apps
in the Settings
App. Go Programming Language *
in the list and uninstall it. C:\Go\bin
from your PATH
environment variable (only if you don't plan on installing another version of golang)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
sudo apt-get remove golang-go
sudo apt-get remove --auto-remove golang-go
This is perfect for Ubuntu 18.18
I just have to answer here after reading such super-basic advice in the other answers.
For MacOS the default paths are:
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
only tab
rm -rvf /usr/local/go/
not works well, but
sudo rm -rvf /usr/local/go/
do.
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
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
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.
Go to the directory
cd /usr/local
Remove it with super user privileges
sudo rm -rf go
In MacOS, you can just do it with brew
:
brew uninstall go
brew install go
brew upgrade go
Source: Stackoverflow.com