How to Uninstall GoLang

Sheeraz Gul Feb 15, 2024
How to Uninstall GoLang

This tutorial demonstrates how to uninstall GoLang on different operating systems.

Uninstall GoLang

Uninstalling the GoLang can be done with a few simple steps. These steps are different for the different operating systems.

Uninstall GoLang on Windows

There are two ways to uninstall the GoLang on windows: the control panel and the command prompt. Follow the steps below to uninstall the GoLang from the Control panel.

  • Open Control Panel from the Start menu.

    Control Panel

  • Click Uninstall a Program under Programs.

    Uninstall a Program

  • Select GoLang and click Uninstall.

    Uninstall Golang

  • After clicking the uninstall, the system may ask for admin permission.
  • Click Yes for the admin permission, and the GoLang will Uninstall Successfully.

Another method in windows to Uninstall GoLang is by the command prompt. We have to run one command to remove the GoLang from our system.

msiexec /x go{{version}}.windows-{{cpu-arch}}.msi /q

The above command will execute the uninstall of the MSI file for the GoLang. After the successful process, the GoLang will be uninstalled.

Uninstall GoLang on Linux, macOS, and FreeBSD

Uninstalling the GoLang from the Linux macOS and FreeBSD is a similar process where we have to follow two main steps.

  1. Uninstall the go directory, usually the /usr/local/go.

  2. Remove the GO from Path environmental variable. To remove the go PATH:

    • For Linux and FreeBSD, edit the $HOME/.profile or /etc/profile.
    • For macOS, we must remove the /etc/paths.d/go file.

We can successfully remove the GoLang from Linux, macOS, and FreeBSD by following the above two steps. This can also be done using the terminal.

If you want to do it from the terminal, follow the steps below.

  • The first step is to find where the go binary is located; for that, we use the which Command in the terminal.
    which go
    

    The output for this command will be something similar to the following.

    /usr/local/go/bin/go
    
  • The second step is to remove the GoLang binary. Run the following command in the terminal.
    sudo rm -rvf /usr/local/go/
    

    The above command will remove the go binary from the given directory.

  • The final step is to remove the go $PATH or $GOPATH, which usually are referenced in the .bash_profile or .bashrc file files. Remove the go path references from these files.

Both methods above can be used to remove the GoLang from Linux, FreeBSD, and macOS.

Author: Sheeraz Gul
Sheeraz Gul avatar Sheeraz Gul avatar

Sheeraz is a Doctorate fellow in Computer Science at Northwestern Polytechnical University, Xian, China. He has 7 years of Software Development experience in AI, Web, Database, and Desktop technologies. He writes tutorials in Java, PHP, Python, GoLang, R, etc., to help beginners learn the field of Computer Science.

LinkedIn Facebook