vscode 安裝外掛程式一直失敗,以下為網上找到的方法,親測可用。
轉自:https://blog.csdn.net/yo_oygo/article/details/79065966
在安裝go外掛程式時,會自動更新很多依賴庫檔案,都是從Github更新下來,但是因為Github的檔案中,多有應用go官網中的檔案,導致,因為網路緣故,不能直接下載,導致安裝失敗,如下:
Installing github.com/nsf/gocode SUCCEEDEDInstalling github.com/uudashr/gopkgs/cmd/gopkgs SUCCEEDEDInstalling github.com/ramya-rao-a/go-outline FAILEDInstalling github.com/acroca/go-symbols FAILEDInstalling golang.org/x/tools/cmd/guru FAILEDInstalling golang.org/x/tools/cmd/gorename FAILEDInstalling github.com/fatih/gomodifytags SUCCEEDEDInstalling github.com/haya14busa/goplay/cmd/goplay SUCCEEDEDInstalling github.com/josharian/impl FAILEDInstalling github.com/rogpeppe/godef SUCCEEDEDInstalling sourcegraph.com/sqs/goreturns FAILEDInstalling github.com/golang/lint/golint FAILEDInstalling github.com/cweill/gotests/... FAILEDInstalling 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-outlinego install github.com/acroca/go-symbolsgo install golang.org/x/tools/cmd/gurugo install golang.org/x/tools/cmd/gorenamego install github.com/josharian/implgo install github.com/rogpeppe/godefgo install github.com/sqs/goreturnsgo install github.com/golang/lint/golintgo install github.com/cweill/gotests/gotestsgo install github.com/ramya-rao-a/go-outlinego install github.com/acroca/go-symbolsgo install golang.org/x/tools/cmd/gurugo install golang.org/x/tools/cmd/gorenamego install github.com/josharian/implgo install github.com/rogpeppe/godefgo install github.com/sqs/goreturnsgo install github.com/golang/lint/golintgo install github.com/cweill/gotests/gotests
按此方法,可以安裝成功。
參考博文:
http://www.pythonsite.com/?p=429
http://blog.csdn.net/langzi7758521/article/details/51313521