Windows64 Visual Studio Code 安裝go插件失敗分析及解決方案

Visual Studio Code安裝go插件報錯git

Visual Studio Code安裝go插件報錯緣由分析
在安裝go插件時,會自動更新不少依賴庫文件,都是從Github更新下來,可是由於Github的文件中,多有應用go官網中的文件,致使,由於網絡緣故,不能直接下載,致使安裝失敗。github

Visual Studio Code安裝go插件報錯解決方案
本文章使用git軟件的Git Bash Here 命令行窗口進行(要求使用,不然git clone時沒法下載插件),進入安裝go時建立的GOPATH目錄,這個目錄通常不是安裝目錄,如不知道請查看「此電腦->屬性->高級系統設置->高級->環境變量->系統變量」中的GOPATH目錄,好比個人是D:\pragrams\go,能夠使用以下命令進入該目錄下的src目錄golang

cd $GOPATH/src網絡

爲了保證使用該方案能正確安裝,清空src目錄下的全部文件夾及文件(建議備份,避免出問題)。.net

建立github.com插件目錄及下載插件
cd $GOPATH/src
mkdir github.com
cd $GOPATH/src/github.com
mkdir acroca cweill derekparker go-delve josharian karrick mdempsky pkg ramya-rao-a rogpeppe sqs uudashr
cd $GOPATH/src/github.com/acroca
git clone https://github.com/acroca/go-symbols.git
cd $GOPATH/src/github.com/cweill
git clone https://github.com/cweill/gotests.git
cd $GOPATH/src/github.com/derekparker
git clone https://github.com/derekparker/delve.git
cd $GOPATH/src/github.com/go-delve
git clone https://github.com/go-delve/delve.git插件

cd $GOPATH/src/github.com/josharian
git clone https://github.com/josharian/impl.git
cd $GOPATH/src/github.com/karrick
git clone https://github.com/karrick/godirwalk.git
cd $GOPATH/src/github.com/mdempsky
git clone https://github.com/mdempsky/gocode.git
cd $GOPATH/src/github.com/pkg
git clone https://github.com/pkg/errors.git
cd $GOPATH/src/github.com/ramya-rao-a
git clone https://github.com/ramya-rao-a/go-outline.git
cd $GOPATH/src/github.com/rogpeppe
git clone https://github.com/rogpeppe/godef.git
cd $GOPATH/src/github.com/sqs
git clone https://github.com/sqs/goreturns.git
cd $GOPATH/src/github.com/uudashr
git clone https://github.com/uudashr/gopkgs.git命令行

建立golang.org插件目錄及下載插件
cd $GOPATH/src
mkdir -p golang.org/x
cd golang.org/x
git clone https://github.com/golang/tools.git
git clone https://github.com/golang/lint.gitcode

手動安裝插件
cd $GOPATH/src
go install github.com/mdempsky/gocode
go install github.com/uudashr/gopkgs/cmd/gopkgs
go install github.com/ramya-rao-a/go-outline
go install github.com/acroca/go-symbols
go install github.com/rogpeppe/godef
go install github.com/sqs/goreturns
go install github.com/derekparker/delve/cmd/dlv
go install github.com/cweill/gotests
go install github.com/josharian/impl
go install golang.org/x/tools/cmd/guru
go install golang.org/x/tools/cmd/gorename
go install golang.org/x/lint/golintblog

檢查插件是否安裝成功
打開(最好重啓一下vs code) Visual Studio Code,在go文件中引入一個包,並寫出「包名.」會有方法提示,例如:我這裏引入的是「math/rand」包,當我寫「rand」的時候會有下圖的提示,那就說明插件安裝成功了,以下:
---------------------
做者:丁丁丁夢濤
來源:CSDN
原文:https://blog.csdn.net/dmt742055597/article/details/85865186
版權聲明:本文爲博主原創文章,轉載請附上博文連接!cmd

相關文章
相關標籤/搜索