Home > Backend Development > Golang > How to delete golang in ubuntu

How to delete golang in ubuntu

PHPz
Release: 2023-04-05 14:14:01
Original
2514 people have browsed it

On Ubuntu systems, if you no longer need to use the Golang programming language, you can remove it from the system. This article will explain how to uninstall Golang in Ubuntu.

  1. Remove Golang Packages

In Ubuntu, you can use the following command to uninstall Golang Packages:

sudo apt purge golang-go
Copy after login

This command will uninstall the Golang programming language and related software packages.

If you also installed other Golang related software packages, please add their names to the command, for example:

sudo apt purge golang-go golang-github-*
Copy after login

Note that when using the purge command, Related configuration files and directories will be completely deleted, so use with caution.

  1. Delete the GOPATH and GOROOT directories

Running Golang requires setting the GOPATH and GOROOT environment variables, so before uninstalling Golang, you need to delete the corresponding directories.

By default, the GOPATH directory is under $HOME/go, and the GOROOT directory is under /usr/local/go. Please use the following command to delete these directories:

rm -rf $HOME/go
sudo rm -rf /usr/local/go
Copy after login
  1. Delete Golang-related paths in PATH

After you uninstall Golang in the system, you need to change the path in the PATH environment variable Golang related paths are deleted. This can be accomplished by editing the /etc/environment file:

sudo vim /etc/environment
Copy after login

Then delete the following two lines:

GOPATH="$HOME/go"
PATH="$PATH:$GOROOT/bin:$GOPATH/bin"
Copy after login

Save and close the file, and restart the computer to ensure PATH Changes to environment variables take effect.

To sum up, the above are the steps to delete Golang on Ubuntu system. If you no longer need to use Golang, you can uninstall it from your system by following the steps above.

The above is the detailed content of How to delete golang in ubuntu. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template