How to remove the Golang?

I tried the answer here. Removed golang, but does the go command still work? but this did not 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 settings, as my GOPATH pointing to another folder named gocode . Now I deleted this folder and the usr/local/go/bin/go .

I also uninstalled GOPATH . However, I can still run go .

How to remove golang?

+21
go
source share
11 answers

You can try

 rm -rvf /usr/local/go/ 

then remove any mention of go , e.g. your ~/.bashrc ; then you need to at least log out and log in.

However, be careful with this. You can severely disrupt your system if something is wrong.

PS. I assume a Linux or POSIX system.

+28
source share

I am using Ubuntu. I spent the whole night fixing it, tried all different solutions, when I print the go version, it is still there, really annoying ... Finally, it worked for me, I hope this helps!

 sudo apt-get remove golang-go sudo apt-get remove --auto-remove golang-go 
+22
source share

August 2019 update

Found that official removal documents worked properly (on Mac OSX).

 $ which go /usr/local/go/bin/go 

In general, to remove:

 $ sudo rm -rf /usr/local/go $ sudo rm /etc/paths.d/go 

Then he made a new installation using homebrew using brew install go . Now I have:

  $ which go /usr/local/bin/go 
+4
source share

For Windows 10:

  • Go to Apps in the Settings app.
  • Locate Go Programming Language * in the list and remove it.
  • Remove C:\Go\bin from the PATH environment variable (only if you do not plan to install another version of golang)
+3
source share

On Mac-OS

  1. If you used the installer, you can remove golang using the same installer.
  2. If you installed from source
     rm -rf /usr/local/go rm -rf $(echo $GOPATH) 

Then delete 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 delete all entries related to go, i.e. GOROOT, GOPATH from ~/.bashrc and run

 source ~/.bashrc 
+2
source share

1- Go to the $ cd / usr / local directory

2- Delete it with superuser privileges $ sudo rm -rf go

0
source share

From the official installation page -

To remove an existing Go installation from your system, delete the go directory. This is usually /usr/local/go on Linux, macOS and FreeBSD, or c:\Go on Windows.

You should also remove the Go bin from the PATH environment variable. Under Linux and FreeBSD, you must edit /etc/profile or $HOME/.profile . If you installed Go with macOS , you must delete the /etc/paths.d/go file. Windows users should read the section on setting environment variables for Windows .

0
source share

tab only
rm -rvf /usr/local/go/
not working well but
sudo rm -rvf /usr/local/go/
to do.

-one
source share

On Linux, we can do this to remove Go completely:

 rm -rf "/usr/local/.go/" rm -rf "/usr/local/go/" 

These two commands remove go and hidden .go files. Now we also need to update the entries in the shell profile.

Open your main file. Basically, I open as sudo gedit ~/.bashrc and sudo gedit ~/.bashrc all mentions of transitions.

You can also do this with the 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 

This will remove the Golang from anywhere. Also run this after executing these commands

source ~/.bash_profile

Tested on Linux 18.04 as well. All this.

-one
source share
 sudo apt-get remove golang-go sudo apt-get remove --auto-remove golang-go 

This is perfect for Ubuntu 18.18

-one
source share

Use this command to remove Golang for Ubuntu.

This will only remove the golang-go package itself.

 sudo apt-get remove golang-go 

Remove golang-go and its dependencies:

 sudo apt-get remove --auto-remove golang-go 
-one
source share

All Articles