Home >Backend Development >Golang >How Do I Uninstall Go Packages Installed with `go get`?

How Do I Uninstall Go Packages Installed with `go get`?

Barbara Streisand
Barbara StreisandOriginal
2024-12-11 05:34:09769browse

How Do I Uninstall Go Packages Installed with `go get`?

Uninstalling Packages Installed via "go get"

To ensure a clean and organized Go installation, it is crucial to know how to remove packages installed using "go get" command. This becomes necessary when packages are installed outside the designated GOPATH, unintentionally cluttering the root Go install.

How to Remove Go Packages

To successfully remove packages previously installed with "go get," follow these steps:

  1. Open a terminal or command prompt.
  2. Navigate to the directory where the package is installed (e.g., $GOPATH/bin).
  3. Execute the following command:
go get package@none

In this command, "package" represents the name of the package you wish to remove. The version part "@none" effectively sets the package to be removed.

Example:

If you installed the "github.com/foo/bar" package with "go get," you can remove it using the following command:

go get github.com/foo/bar@none

This command will remove the "github.com/foo/bar" package from your Go installation. Note that this action will not delete the package directory or its contents; it merely uninstalls the package and removes its entry from the Go path.

The above is the detailed content of How Do I Uninstall Go Packages Installed with `go get`?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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