在VScode中下載並啟用GO插件的時候,會提示需要安裝一些依賴(如下所示)
點擊 install all后:
Tools environment: GOPATH=D:\BJ-Golang\gocode_lm
Installing 8 tools at D:\BJ-Golang\gocode_lm\bin in module mode.
go-outline
gotests
gomodifytags
impl
goplay
dlv
staticcheck
gopls
報錯如下:
Installing github.com/ramya-rao-a/go-outline@latest FAILED
{
"killed": false,
"code": 1,
"signal": null,
"cmd": "E:\\programs\\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: module github.com/ramya-rao-a/go-outline: Get \"https://proxy.golang.org/github.com/ramya-rao-a/go-outline/@v/list\": dial tcp 142.251.42.241:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.\n"
}
參考:
在%GOPATH%\src\目錄下,建立路徑golang.org\x
(我的GOPATH=D:\BJ-Golang\gocode_lm)
進入到%GOPATH%\src\golang.org\x,下載需要工具的源碼git clone https://github.com/golang/tools.git
同樣的步驟創建%GOPATH%\src\github.com\golang,然后git clone https://github.com/golang/tools.git
進入到%GOPATH%下,執行
go install github.com/ramya-rao-a/go-outline
//其中github.com/ramya-rao-a/go-outline部分根據前面自動install中的報錯更改即可
//例如:報錯信息:
//dlv: failed to install dlv(github.com/go-delve/delve/cmd/dlv@latest): Error: Command failed: E:\programs\go\bin\go.exe install -v github.com/go-delve/delve/cmd/dlv@latest
//go: github.com/go-delve/delve/cmd/dlv@latest: module github.com/go-delve/delve/cmd/dlv: Get "https://proxy.golang.org/github.com/go-delve/delve/cmd/dlv/@v/list": dial tcp 142.251.43.17:443: connectex: A connection //attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
//則 go install github.com/go-delve/delve/cmd/dlv
//如果此時報錯,則改為以下順序:
//go get github.com/go-delve/delve/cmd/dlv
//go install github.com/go-delve/delve/cmd/dlv