How to uninstall Golang?

后端 未结 13 1506
猫巷女王i
猫巷女王i 2020-12-29 00:55

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

相关标签:
13条回答
  • 2020-12-29 01:37
    1. Go to the directory

      cd /usr/local
      
    2. Remove it with super user privileges

      sudo rm -rf go
      
    0 讨论(0)
  • 2020-12-29 01:38

    On a Mac-OS system

    1. If you have used an installer, you can uninstall golang by using the same installer.
    2. If you have installed from source
      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
    
    0 讨论(0)
  • 2020-12-29 01:38

    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
    
    0 讨论(0)
  • 2020-12-29 01:38

    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.

    0 讨论(0)
  • 2020-12-29 01:42

    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 or c:\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.

    0 讨论(0)
  • 2020-12-29 01:44

    only tab
    rm -rvf /usr/local/go/
    not works well, but
    sudo rm -rvf /usr/local/go/
    do.

    0 讨论(0)
提交回复
热议问题