golang 刪除用go get 安裝的package

下面這兩種方法都須要手動刪除package的源碼目錄。git

一、手動刪除github

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.windows

直接刪除源文件目錄及編譯後的package目錄便可。在源碼目錄$GOPATH/src下找到你要刪除的package名,直接刪除;而後在$GOPATH/pkg/<architecture>下刪除編譯後的package目標文件目錄。spa

二、用go clean命令自動刪除編譯後的package目錄,再手動刪除源文件目錄code

如:遞歸

go get -u github.com/motemen/gore文檔

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

# 執行刪除編譯後的package目錄源碼

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

# 若是還有未刪除的目錄,那只有手動刪除了

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

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

 

注意:

請必定要包含三個點號 ... ,這樣就不會遞歸刪除子package,如本例中的 gore/gocode。-i 參數表示刪除由 go install 所建立的archive或二進制文檔。

相關文章
相關標籤/搜索