【转】golang 删除用go get 安装的package

原文:https://www.cnblogs.com/welhzh/p/8848021.html

-------------------------------------

下面这两种方法都需要手动删除package的源码目录。

1、手动删除

It's safe to just delete the source directory and compiled package file. Find the source directory under $GOPATH/src and the package file under $GOPATH/pkg/<architecture>, for example: $GOPATH/pkg/windows_amd64.

直接删除源文件目录及编译后的package目录即可。在源码目录$GOPATH/src下找到你要删除的package名,直接删除;然后在$GOPATH/pkg/<architecture>下删除编译后的package目标文件目录。

2、用go clean命令自动删除编译后的package目录,再手动删除源文件目录

如:

go get -u github.com/motemen/gore

# -n 表示只打印命令,不执行
go clean --n github.com/motemen/gore...

# 执行删除编译后的package目录

go clean -i github.com/motemen/gore...

# 如果还有未删除的目录,那只有手动删除了

$ rmdir $GOPATH/pkg/darwin_amd64/github.com/motemen/gore

$ rm -rf $GOPATH/src/github.com/motemen/gore

注意:

请一定要包含三个点号 ... ,这样就不会递归删除子package,如本例中的 gore/gocode。-i 参数表示删除由 go install 所创建的archive或二进制文档。

原文地址:https://www.cnblogs.com/oxspirt/p/15070050.html