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?
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.
1- Go to the directory $ cd /usr/local
2- Remove it with super user privileges $ sudo rm -rf go
only tabrm -rvf /usr/local/go/
not works well, butsudo rm -rvf /usr/local/go/
do.
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
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)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.
sudo apt-get remove golang-go
sudo apt-get remove --auto-remove golang-go
This is perfect for Ubuntu 18.18
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
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
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.
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