Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a Go package downloaded with "go get" command?

Tags:

I want to know if there is golang way to delete or remove a go package. To be simpler, opposite to go get command.

e.g.  $ go get <PACKAGE_NAME>  $ go delete <PACKAGE_NAME>    (Looking for similar functionality) 

Please NOTE that I am aware that we can remove the downloaded files from src and pkg directory manually by using rm command. But the problem is that system command rm is not aware of your go specific stuffs (etc. to look inside $GOPATH/pkg .. ) and this is an extra step for the user while using rm . I am looking for something which all package managers provides.. as mentioned in one comment.. (npm uninstall, pip uninstall etc..).

like image 403
Sitesh Avatar asked Oct 29 '18 15:10

Sitesh


People also ask

How do you remove go get packages?

If you want to remove the packages installed with the go get command – we can directly delete the files/directories related to the installed package. We have to delete the source directory under $GOPATH/src and compiled package file under $GOPATH/pkg/<architecture>.

Where are packages installed with go get?

The packages from the standard library are available at the “pkg” subdirectory of the GOROOT directory. When you install Go, an environment variable GOROOT will be automatically added to your system for specifying the Go installer directory.

How do you use go GET command?

Go The Go Command Go Get go get downloads the packages named by the import paths, along with their dependencies. It then installs the named packages, like 'go install'. Get also accepts build flags to control the installation. When checking out a new package, get creates the target directory $GOPATH/src/<import-path> .

How do you clean go modules?

go clean -modcache This command is used to clear the mod cache which is stored at $GOPATH/pkg/mod . This command is used to remove the installed packages. The -modcache flag removes the entire module download cache, including unpacked source code of versioned dependencies.


1 Answers

You can just delete it from you disk:

rm -r $GOPATH/src/<PACKAGE_NAME> 

This will remove the package completely. Alas, there is no tool or go command for removing packages. But this should be simple enough.

like image 172
mbuechmann Avatar answered Sep 22 '22 13:09

mbuechmann