下面這兩種方法都需要手動刪除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 -i -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或二進制文檔。