VSCode安裝go相關(guān)插件失敗的簡單解決方案
1. GO環(huán)境信息
C:\Users\home>go version
go version go1.18.2 windows/amd64
C:\Users\home>
安裝go插件之后,VSCode開始寫代碼會提示安裝其他插件,錯誤信息如下:
Installing 8 tools at C:\Go\repository\bin in module mode.
gotests
gomodifytags
impl
goplay
dlv
staticcheck
gopls
go-outline
Installing github.com/cweill/gotests/gotests@latest FAILED
Installing github.com/fatih/gomodifytags@latest FAILED
Installing github.com/josharian/impl@latest FAILED
Installing github.com/go-delve/delve/cmd/dlv@latest FAILED
Installing github.com/haya14busa/goplay/cmd/goplay@latest FAILED
Installing github.com/go-delve/delve/cmd/dlv@latest FAILED
Installing honnef.co/go/tools/cmd/staticcheck@latest FAILED
Installing honnef.co/go/tools/cmd/staticcheck@latest FAILED
Installing golang.org/x/tools/gopls@latest FAILED
Installing github.com/ramya-rao-a/go-outline@latest FAILED
無法下載插件只能通過設(shè)置GOPROXY代理解決
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/
修改之后
Installing 8 tools at C:\Go\repository\bin in module mode.
gotests
gomodifytags
impl
goplay
dlv
staticcheck
gopls
go-outline
Installing github.com/cweill/gotests/gotests@latest (C:\Go\repository\bin\gotests.exe) SUCCEEDED
Installing github.com/fatih/gomodifytags@latest (C:\Go\repository\bin\gomodifytags.exe) SUCCEEDED
Installing github.com/josharian/impl@latest (C:\Go\repository\bin\impl.exe) SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv@latest (C:\Go\repository\bin\dlv.exe) SUCCEEDED
Installing github.com/haya14busa/goplay/cmd/goplay@latest (C:\Go\repository\bin\goplay.exe) SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv@latest (C:\Go\repository\bin\dlv.exe) SUCCEEDED
Installing honnef.co/go/tools/cmd/staticcheck@latest (C:\Go\repository\bin\staticcheck.exe) SUCCEEDED
Installing honnef.co/go/tools/cmd/staticcheck@latest (C:\Go\repository\bin\staticcheck.exe) SUCCEEDED
Installing golang.org/x/tools/gopls@latest (C:\Go\repository\bin\gopls.exe) SUCCEEDED
1 tools failed to install.
impl: failed to install impl(github.com/josharian/impl@latest): Error: Command failed: C:\Go\bin\go.exe install -v github.com/josharian/impl@latest
go: github.com/josharian/impl@latest: module github.com/josharian/impl: reading https://mirrors.aliyun.com/goproxy/github.com/josharian/impl/@v/list: 404 Not Found
Installing golang.org/x/tools/gopls@latest (C:\Go\repository\bin\gopls.exe) SUCCEEDED
Installing github.com/ramya-rao-a/go-outline@latest FAILED
{
"killed": false,
"code": 1,
"signal": null,
"cmd": "C:\\Go\\bin\\go.exe install -v github.com/ramya-rao-a/go-outline@latest",
"stdout": "",
"stderr": "go: github.com/ramya-rao-a/go-outline@latest: no matching versions for query \"latest\"\n"
}
1 tools failed to install.
go-outline: failed to install go-outline(github.com/ramya-rao-a/go-outline@latest): Error: Command failed: C:\Go\bin\go.exe install -v github.com/ramya-rao-a/go-outline@latest
go: github.com/ramya-rao-a/go-outline@latest: no matching versions for query "latest"
還是有一個報錯,未能成功安裝全部插件,然后切換到%GOPATH%\pkg\mod\github.com目錄,例如
C:\Go\repository\pkg\mod\github.com
執(zhí)行如下命令
git clone https://github.com/josharian/impl
然后切換到GOPATH目錄,執(zhí)行如下命令
PS C:\go\repository> go install github.com/josharian/impl@latest PS C:\go\repository> go install github.com/ramya-rao-a/go-outline@latest go: downloading github.com/ramya-rao-a/go-outline v0.0.0-20210608161538-9736a4bde949 go: downloading golang.org/x/tools v0.1.1 PS C:\go\repository>
上述命令結(jié)束之后,重啟VSCode,這下寫Go代碼就沒有問題了。

總結(jié)
到此這篇關(guān)于VSCode安裝go相關(guān)插件失敗的簡單解決方案的文章就介紹到這了,更多相關(guān)VSCode安裝go插件失敗內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Go語言實現(xiàn)控制臺輸入&生成隨機數(shù)詳解
這篇文章主要介紹了Go語言如何實現(xiàn)控制臺輸入&生成隨機數(shù),文中通過示例代碼介紹的非常詳細,對大家的學習有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-05-05

