Uninstalling Go (golang)

I'm trying to install drive, which requires Go.

I did:

sudo apt-get install golang git mercurial

which successfully installed version 1.2.1. Unfortunately, when I tried to install drive with:

go get -u github.com/odeke-em/drive/cmd/drive

I encountered this error, and now I see I need at least version 1.4 of Go to make things work. The golang doc says you must first remove the existing version.

So I came across this question that says to simply use:

sudo apt-get purge golang

which gave me this output:

The following packages will be REMOVED:
golang*
0 upgraded, 0 newly installed, 1 to remove and 16 not upgraded.
After this operation, 92.2 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 263287 files and directories currently installed.)
Removing golang (2:1.2.1-2ubuntu1) ...

(no more output after the three dots—just back to the prompt).

But I still see the go directory in /usr/lib/, and there's also still a gopath directory in my home directory.

which I think was created when I did:

$ cat << ! >> ~/.bashrc
> export GOPATH=\$HOME/gopath
> export PATH=\$GOPATH:\$GOPATH/bin:\$PATH
> !
$ source ~/.bashrc # To reload the settings and get the newly set ones # Or open a fresh terminal

during the installation (to create the GOPATH).

So I'm not sure if the uninstall was successful and if it's safe to install a newer version of Go.

Ubuntu 14.04 LTS


I spent a whole morning fixing this, tried all different solutions, when I type go version, it's still there, really annoying...

Thank bloody frigging god, this worked for me.

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

Check this original post :D


I realize that this is a little old, but the answers at https://golang.org/doc/manage-install#uninstalling may help you.

Essentially just removing the directories /usr/local/go or /usr/lib/go and modifying your path at /etc/profile or $HOME/.profile should be enough.