How to uninstall Go?

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 go?

250812 次浏览

你可以试试

rm -rvf /usr/local/go/

然后删除任何提及 go的内容,例如你的 ~/.bashrc; 然后你至少需要注销和登录。

但是,在这样做的时候要小心。如果有什么地方出错了,你可能会严重地破坏你的系统。

PS. I am assuming a Linux or POSIX system.

  1. 进入目录

    cd /usr/local
    
  2. 用超级用户权限删除它

    sudo rm -rf go
    

只有账单
rm -rvf /usr/local/go/
not works well, but
sudo rm -rvf /usr/local/go/
做。

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... 最后这个对我有用,希望这个对我有帮助!

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

For Windows 10:

  1. Settings应用程序中转到 Apps
  2. Look for Go Programming Language * in the list and uninstall it.
  3. 从你的 PATH环境变量删除 C:\Go\bin(除非你不打算安装另一个版本的 golang)

在 linux 上,我们可以像这样完全删除:

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.

打开你的基本文件。通常我打开这样的 sudo gedit ~/.bashrc和删除所有去提到。

你也可以在 ubuntu 中使用 sed 命令

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

也在 linux 18.04上测试过,仅此而已。

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

This is perfect for Ubuntu 18.18

在 Mac-OS 系统上

  1. If you have used an installer, you can uninstall golang by using the same installer.
  2. 如果您已从源代码安装
    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

在 Linux 系统上

rm -rf /usr/local/go
rm -rf $(echo $GOPATH)

然后,从 ~/.bashrc中删除所有与 go 相关的条目,即 GOROOT、 GOPATH 并运行

source ~/.bashrc

Use this command to uninstall Golang for Ubuntu.

这将只删除 golang-go 包本身。

sudo apt-get remove golang-go

卸载 golang-go 及其依赖项:

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

更新(2022年9月)

官方页面 已经更改了卸载帮助的路径以及帮助文本。这是它现在说的。

卸载 Go

You can remove Go from your system using the steps 在这个主题中描述。

Linux/macOS/FreeBSD

  1. 删除目录。
    这通常是 我是 usr/local/go。

  2. 从 PATH 环境变量中删除 Go bin 目录。
    在 Linux 和 FreeBSD 下,编辑/etc/profile 或 $HOME/. profile 安装使用 macOS 包,删除/etc/paths.d/Go 文件。

窗户

移除 Go 的最简单方法是通过 视窗控制面板:

  1. 在“控制面板”中,双击“添加/删除程序”。
  2. 添加/删除 程序,选择“编程语言”,单击“卸载”,然后按下 提示。

For removing Go with tools, you can also use the command 电话:

  • 通过运行以下命令使用命令行卸载:
    msiexec /x go\{\{version}}.windows-\{\{cpu-arch}}.msi /q
    注意: 使用此 卸载过程将自动删除 Windows 由原始安装创建的环境变量。

Original Answer

官方安装页-

To remove an existing Go installation from your system delete the go 这通常是 Linux、 macOS 和 Windows 下的 FreeBSD 或 c:\Go

您还应该从 PATH 环境中删除 Go bin目录 在 Linux 和 FreeBSD 下,您应该编辑 /etc/profile或 如果你安装与 macOS package去,然后你 should remove the /etc/paths.d/go file. Windows users should read the 关于 在 Windows 下设置环境变量的部分。

2019年8月最新情况

Found the 正式卸载文档 worked as expected (on Mac OSX).

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

总之,卸载:

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

然后,使用 brew install go重新安装了自制程序。现在,我有:

 $ which go
/usr/local/bin/go

在 Mac-OS Catalina 上

  1. 需要在 rm-rf/usr/local/go < strong > sudo rm-rf/usr/local/go 之前添加 sudo 否则,我们将遇到权限拒绝

  2. Sudo vim ~/. profile Sudo ~/. bash _ profile删除 Export PATH = $PATH: $GOPATH/BIN或任何相关内容 go lang

  3. If you use Zsh shell, then you need to remove the above line to ~/.zshrc file.

希望对你有所帮助:)

在 MacOS 中,你可以直接使用 brew:

brew uninstall go
brew install go
brew upgrade go

我只需要在这里回答在阅读了这些超级基本的建议在其他的答案。

对于 MacOS,默认路径是:

  1. /user/bracicot/go (工作目录)
  2. /usr/local/go (install dir)

卸载时删除两个目录。
如果您已经手动安装,显然这些目录可能在其他地方。

一个脚本,我偶然安装到 /usr/local/.go/一个隐藏的文件夹,因为许可... 这可能会绊倒你。

终端机检查:

echo $GOPATH
echo $GOROOT
#and
go version

对我来说,删除所有的去文件夹我仍然得到一个去版本。

挖掘我的系统路径 echo $PATH

/Users/bracicot/google-cloud-sdk/bin:/usr/local/bin:

显示了一些地方,以检查仍然存在的去文件,如 /usr/local/bin

另一个用户提到: /etc/paths.d/go

您可能还需要删除 GOPATHGOROOT环境变量。
检查. zshsrc 和或. bash _ profile。
Or you can unset GOPATH and unset GOROOT

要在 MacOS 上卸载 go,请执行以下操作: 在终端类型 which go上,它将返回类似于 /usr/local/go/bin/go的路径 Go to the root folder of go which is /usr/local/go/ and type on the terminal rm -rf /usr/local/go/ . you may get permission denied depending on your system setup, so the command should be prefixed with sudo like this

sudo rm -rf /usr/local/go/

它会要求输入你的密码,只要输入就可以了。