12

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

  • 1
    To downvoter: Are you kidding me? – yroc Mar 4 '16 at 15:34
22

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

  • --auto-remove force it to remove all from linux-images which consumed around 10 minutes. @loukaswho – alper Aug 27 '18 at 13:40
9

I realize that this is a little old, but the answers at https://golang.org/doc/install#uninstall 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.

3

best way to uninstall is to open terminal and type

sudo apt-get uninstall purge golang*

this removes every package associated with go. Then you can run

sudo apt-get update

But if you did that and nothing worked, you can do this

sudo rm -rf /usr/local/go

then try running the purge again. But You should update to Go 1.8, which sets the GOPATH for you. But hey! before updating first remove existing golang.

1

First you have to remove all the go-packages in your system by type this code from terminal

sudo apt-get purge golang*

Then follow the instructions to download and install golang

Official golang website

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.