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 o
Go to the directory
cd /usr/local
Remove it with super user privileges
sudo rm -rf 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
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.
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.
only tab
rm -rvf /usr/local/go/
not works well, but
sudo rm -rvf /usr/local/go/
do.