首頁 > 軟體

教你一招完美解決vscode安裝go外掛失敗問題

2022-07-20 14:02:46

前置

https://studygolang.com/dl下載go1.14.6.windows-amd64.msi安裝即可,安裝路徑選擇預設,安裝完成後會自動幫你設定環境變數不用自己設定了

開啟cmd,檢視是否安裝完成

這樣就代表已經成功安裝了

用vscode新建一個go檔案

vscode會提示你安裝go外掛

點選install all

這時候會安裝失敗

Installing github.com/mdempsky/gocode FAILED
Installing github.com/uudashr/gopkgs/v2/cmd/gopkgs FAILED
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/cweill/gotests/… FAILED
Installing github.com/fatih/gomodifytags FAILED
Installing github.com/josharian/impl FAILED
Installing github.com/davidrjenni/reftools/cmd/fillstruct FAILED
Installing github.com/haya14busa/goplay/cmd/goplay FAILED
Installing github.com/godoctor/godoctor FAILED
Installing github.com/go-delve/delve/cmd/dlv FAILED
Installing github.com/stamblerre/gocode FAILED
Installing github.com/rogpeppe/godef FAILED
Installing github.com/sqs/goreturns FAILED
Installing golang.org/x/lint/golint FAILED

原因你懂的

使用go mod 代理來安裝

https://goproxy.io是一個國內的代理

執行

# 舊版,已廢棄
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct
# 新版改成如下連結
go env -w GO111MODULE=on
go env -w GOPROXY=https://proxy.golang.com.cn,direct

關閉vscode重新開啟,再次點選install all

成功安裝

開啟go mod 代理後也可以手動安裝

go get -u -v github.com/mdempsky/gocode
go get -u -v github.com/uudashr/gopkgs/v2/cmd/gopkgs
go get -u -v github.com/ramya-rao-a/go-outline
go get -u -v github.com/acroca/go-symbols
go get -u -v golang.org/x/tools/cmd/guru
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v github.com/cweill/gotests/...
go get -u -v github.com/fatih/gomodifytags
go get -u -v github.com/josharian/impl
go get -u -v github.com/davidrjenni/reftools/cmd/fillstruct
go get -u -v github.com/haya14busa/goplay/cmd/goplay
go get -u -v github.com/godoctor/godoctor
go get -u -v github.com/go-delve/delve/cmd/dlv
go get -u -v github.com/stamblerre/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/sqs/goreturns
go get -u -v golang.org/x/lint/golint

如圖

總結 

到此這篇關於一招完美解決vscode安裝go外掛失敗問題的文章就介紹到這了,更多相關vscode安裝go外掛失敗內容請搜尋it145.com以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援it145.com!


IT145.com E-mail:sddin#qq.com