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

How Do I Remove Packages Installed with `go get`?

Mary-Kate Olsen
Release: 2024-12-06 07:41:10
Original
989 people have browsed it

How Do I Remove Packages Installed with `go get`?

Removing Packages Installed with 'go get'

Unintentionally installing packages without setting GOPATH can lead to a cluttered Go installation directory. To remove such packages, follow these steps:

1. Identify the Installed Package Name:

Run the following command to list all packages installed using 'go get':

go list -m all
Copy after login

This command will display a list of installed packages, including their names.

2. Remove the Package:

Use the following command to remove a package:

go get package@none
Copy after login

Replace 'package' with the name of the package you wish to remove.

The '@none' part of the command specifies that you want to set the package version to 'none'. This effectively removes the package from your installation.

Example:

To remove the 'github.com/example/testpkg' package, you would run the following command:

go get github.com/example/testpkg@none
Copy after login

By following these steps, you can selectively remove packages installed through 'go get' and maintain a clean and organized Go installation directory.

The above is the detailed content of How Do I Remove Packages Installed with `go get`?. 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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template