删除已安装的软件包得到

我跑去go get package下载一个包之前,得知我需要设置我的GOPATH否则该包GOPATH我的根去安装(我宁愿保持我的安装干净,分离核心从自定义)。 如何删除以前安装的软件包?

删除源目录和编译的软件包文件是安全的。 find$GOPATH/src下的源目录和$GOPATH/pkg/<architecture>下的包文件,例如: $GOPATH/pkg/windows_amd64

你可以删除档案文件和可执行的二进制文件go install (或go get )产生一个包与go clean -i importpath... 这些通常分别位于$GOPATH/pkg$GOPATH/bin

然后需要从$GOPATH/src手动删除源代码。

go clean有一个干运行-n标志打印什么将运行而不执行它,所以你可以肯定(见go help clean )。 它也有一个诱人的-r标志recursion清理依赖关系,你可能不想实际使用,因为你从干运行中会看到它会删除大量的标准库归档文件!

一个完整的例子,你可以基于脚本,如果你喜欢:

 $ go get -u github.com/motemen/gore $ which gore /Users/ches/src/go/bin/gore $ go clean -i -n github.com/motemen/gore... cd /Users/ches/src/go/src/github.com/motemen/gore rm -f gore gore.exe gore.test gore.test.exe commands commands.exe commands_test commands_test.exe complete complete.exe complete_test complete_test.exe debug debug.exe helpers_test helpers_test.exe liner liner.exe log log.exe main main.exe node node.exe node_test node_test.exe quickfix quickfix.exe session_test session_test.exe terminal_unix terminal_unix.exe terminal_windows terminal_windows.exe utils utils.exe rm -f /Users/ches/src/go/bin/gore cd /Users/ches/src/go/src/github.com/motemen/gore/gocode rm -f gocode.test gocode.test.exe rm -f /Users/ches/src/go/pkg/darwin_amd64/github.com/motemen/gore/gocode.a $ go clean -i github.com/motemen/gore... $ which gore $ tree $GOPATH/pkg/darwin_amd64/github.com/motemen/gore /Users/ches/src/go/pkg/darwin_amd64/github.com/motemen/gore 0 directories, 0 files # If that empty directory really bugs you... $ rmdir $GOPATH/pkg/darwin_amd64/github.com/motemen/gore $ rm -rf $GOPATH/src/github.com/motemen/gore 

一定要包括...在importpath,因为看起来,如果一个软件包包含一个可执行文件go clean -i只会删除,而不是存档文件的子包,如gore/gocode在这个例子。

请注意,这些信息基于Go 1.5.1版本中的go工具。