在安裝go外掛程式時,會自動更新很多依賴庫檔案,都是從Github更新下來,但是因為Github的檔案中,多有應用go官網中的檔案,導致,因為網路緣故,不能直接下載,導致安裝失敗,如下:
- Installing github.com/nsf/gocode SUCCEEDED
- Installing github.com/uudashr/gopkgs/cmd/gopkgs SUCCEEDED
- Installing github.com/ramya-rao-a/go-outline FAILED
- Installing github.com/acroca/go-symbols FAILED
- Installing golang.org/x/tools/cmd/guru FAILED
- Installing golang.org/x/tools/cmd/gorename FAILED
- Installing github.com/fatih/gomodifytags SUCCEEDED
- Installing github.com/haya14busa/goplay/cmd/goplay SUCCEEDED
- Installing github.com/josharian/impl FAILED
- Installing github.com/rogpeppe/godef SUCCEEDED
- Installing sourcegraph.com/sqs/goreturns FAILED
- Installing github.com/golang/lint/golint FAILED
- Installing github.com/cweill/gotests/... FAILED
- Installing github.com/derekparker/delve/cmd/dlv SUCCEEDED
-
- 8 tools failed to install.
這些失敗的庫,不是沒有下載下來,而是以來的檔案在go官網上,導致失敗。以下為解決辦法,
1、在%GOPATH%\src\ 目錄下,建立golang.org 檔案夾,並再建立x檔案夾。 目錄為 "%GOPATH\src\golang.org\x\"
2、完成目錄切換後,開始下載外掛程式包:
git clone https://github.com/golang/tools.git tools
3、執行完以後,會多一個tools檔案夾。
4、開啟vsCode終端,切換到 終端,進入“%GOPATH”目錄,執行
go install github.com/ramya-rao-a/go-outline
go install github.com/acroca/go-symbols
go install golang.org/x/tools/cmd/guru
go install golang.org/x/tools/cmd/gorename
go install github.com/josharian/impl
go install github.com/rogpeppe/godef
go install github.com/sqs/goreturns
go install github.com/golang/lint/golint
go install github.com/cweill/gotests/gotests
go install github.com/ramya-rao-a/go-outline
go install github.com/acroca/go-symbols
go install golang.org/x/tools/cmd/guru
go install golang.org/x/tools/cmd/gorename
go install github.com/josharian/impl
go install github.com/rogpeppe/godef
go install github.com/sqs/goreturns
go install github.com/golang/lint/golint
go install github.com/cweill/gotests/gotests
按此方法,可以安裝成功。
參考博文:
http://www.pythonsite.com/?p=429
http://blog.csdn.net/langzi7758521/article/details/51313521