DEV Community

Coder
Coder

Posted on • Edited on

How to uninstall Golang in 3 easy steps via terminal

If you are looking to uninstall Golang, you will be pleased to know that it can be done in just three easy steps via the terminal. Golang is a programming language that is widely used, however, there may be instances where you no longer require it on your system. In this post, we will guide you through the process of uninstalling Golang on your Mac or Windows computer.

Why Should You Uninstall Golang?

Before we proceed, it is essential to understand why you would need to uninstall Golang. There could be several reasons why you would want to remove it. Some of the reasons include:

  • You are not using Golang anymore.
  • You need to free up space on your hard drive.
  • You are experiencing issues with the Golang installation.

Step 1: Confirm Whether Golang is Installed on Your Computer

Before we proceed with the uninstallation process, we need to confirm whether Golang is installed on your computer. To do this, follow these steps:

Mac

  • Open the terminal by clicking on the Launchpad icon > type "terminal" in the search box > click on Terminal.
  • Type the following command: go version and press Enter.
  • If the command outputs a version number, Golang is installed on your system.

Windows

  • Open the Command Prompt by clicking on Start > type "cmd" in the search box > click on the Command Prompt application.
  • Type the following command: go version and press Enter.
  • If the command outputs a version number, Golang is installed on your system.

Step 2: Uninstall Golang

Once we have confirmed that Golang is installed on your system, we can proceed with the uninstallation process. Follow these steps:

Mac

  • Open the terminal.
  • Type the following command: sudo rm -rf /usr/local/go and press Enter.
  • Enter your password when prompted.
  • This will remove the Golang installation from your system.

Windows

  • Open the Command Prompt.
  • Type the following command: rmdir /s c:\Go and press Enter.
  • This will remove the Golang installation from your system.

Step 3: Remove Golang Path from Environment Variables

The final step is to remove the Golang path from the environment variables. Follow these steps to do so:

Mac

  • Open the terminal.
  • Type the following command: sudo nano /etc/paths and press Enter.
  • This will open the environment variables file in the nano editor.
  • Scroll down to the line that contains the Golang path.
  • Delete the line that contains the path.
  • Press Ctrl + X to exit.
  • Type Y to save the changes.
  • Type Enter to confirm the changes.

Windows

  • Open the start menu and search for "advanced system settings."
  • Click on "View advanced system settings."
  • Click on the "Environment Variables" button.
  • Find the Path variable under "System Variables" and click "Edit."
  • Find the line that contains the Golang path.
  • Delete the line that contains the path.
  • Click "OK" to save the changes.

Conclusion

In summary, we have covered the three easy steps to uninstall Golang via the terminal. It is important to note that Golang is a useful programming language, and you should only uninstall it when necessary. We hope that this guide has been helpful to you. If you have any questions or comments, please let us know in the comments section below.

Top comments (0)