vscode安裝go所有插件


原文節選自https://blog.csdn.net/xiazhipeng1000/article/details/109584712

備用以為后用

 

時間很重要 

最好使用SDK版本version go1.15.的   16會報錯

vscode版本:1.56.2

go版本:version go1.15.2 windows/amd64

git客戶端版本:Git-2.29.2.2-64-bit

 

需要提前安裝go、vscode、git客戶端,配置git環境,配置go環境,配置環境變量GOPATH  , GOROOT , PATH 。

 

安裝插件

 

需要手動從github上面將包下載下來

在src目錄下面建立兩個目錄

– src
​ |–golang.org
---- |–x
​ |–github.com

有些包是需要放到github.com,有另外一部分是需要放到golang.org\x這個文件夾中的

下面就一個一個的下載包

gopkgs包

在src的gitbub.com文件夾下,使用cmd命令窗口輸入,一定要按照這個文件目錄生成,要不然沒有辦法安裝,

git clone https://github.com/uudashr/gopkgs.git uudashr/gopkgs

這個包的安裝需要另外兩個輔助包:

git clone https://github.com/pkg/errors pkg/errors

git clone https://github.com/karrick/godirwalk.git karrick/godirwalk

下載完上面的兩個輔助包,就可以進行安裝了

使用cmd命令行窗口(在任意目錄下),輸入下面的命令就可以安裝了:

go install github.com/uudashr/gopkgs/v2/cmd/gopkgs

安裝完成之后,在src同級的bin目錄下會生成gocode.exe

 

go-outline包

在github.com目錄下面,使用下面的命令下載包:

git clone https://github.com/ramya-rao-a/go-outline.git ramya-rao-a/go-outline

安裝:(在任意目錄下面,下面都一樣)

go install github.com/ramya-rao-a/go-outline

go-symbols包

下載:在github.com目錄下面

git clone https://github.com/acroca/go-symbols.git acroca/go-symbols

安裝:

go install github.com/acroca/go-symbols

安裝完成之后,在bin下會生成go-symbols.exe

 

guru、gorename包

這兩個包在tools這個大包中,我們把這個大包下載下來,這個比較大,下載比較慢

下載:在golang.org/x目錄下面,沒有x這個目錄新建一個,這個就是字母x,不是指代

git clone https://github.com/golang/tools.git tools

這個的安裝也需要輔助包:

git clone https://github.com/golang/xerrors.git xerrors (在golang.org/x目錄下)

git clone https://github.com/golang/mod.git mod(在golang.org/x目錄下)

安裝:

go install golang.org/x/tools/cmd/guru

go install golang.org/x/tools/cmd/gorename

在bin目錄下面會出現guru.exe、gorename.exe

 

gotests包

下載:在github.com目錄下面,這個有點慢

git clone https://github.com/cweill/gotests.git cweill/gotests

安裝:

go install github.com/cweill/gotests

gomodifytags包

下載:在github.com目錄下面

git clone https://github.com/fatih/gomodifytags.git fatih/gomodifytags

這個也需要輔助包:在github.com目錄下面

git clone https://github.com/fatih/structtag.git fatih/structtag

git clone https://github.com/fatih/camelcase.git fatih/camelcase

安裝:

go install github.com/fatih/gomodifytags

在bin下會出現一個gomodifytags.exe

 

impl包

下載:在github.com目錄下面

git clone https://github.com/josharian/impl.git josharian/impl

安裝:

go install github.com/josharian/impl

在bin下會出現impl.exe

 

fillstruct包

下載:在github.com目錄下面,這個有點慢

git clone https://github.com/davidrjenni/reftools.git davidrjenni/reftools

安裝:

go install github.com/davidrjenni/reftools/cmd/fillstruct

在bin下會出現fillstruct.exe

goplay包

下載:在github.com目錄下面

git clone https://github.com/haya14busa/goplay haya14busa/goplay

這個需要輔助包:在github.com目錄下面

git clone https://github.com/skratchdot/open-golang.git skratchdot/open-golang

安裝:

go install github.com/haya14busa/goplay/cmd/goplay

在bin目錄下面會出現goplay.exe

 

godoctor包

下載:在github.com目錄下面,這個有點慢

git clone https://github.com/godoctor/godoctor.git godoctor/godoctor

安裝:

go install github.com/godoctor/godoctor

在bin目錄下會出現godoctor.exe

dlv包

下載:在github.com目錄下面,這個有點慢

git clone https://github.com/go-delve/delve.git go-delve/delve

安裝:

go install github.com/go-delve/delve/cmd/dlv

會在bin目錄下面生成dlv.exe

gocode-gomod包

下載:在github.com目錄下面,這個有點慢

git clone https://github.com/stamblerre/gocode.git stamblerre/gocode

安裝:

go install github.com/stamblerre/gocode

在bin目錄下面會出現gocode-gomod.exe

godef包

下載:在github.com目錄下面,這個有點慢

git clone https://github.com/rogpeppe/godef.git rogpeppe/godef

安裝:

go install github.com/rogpeppe/godef

在bin目錄下面會出現godef.exe文件

goreturns包

下載:在github.com目錄下面,這個有點慢

git clone https://github.com/sqs/goreturns.git sqs/goreturns

安裝:

go install github.com/sqs/goreturns

在bin目錄下會生成goreturns.exe

lint包

下載:在golang.org/x目錄下面

git clone https://github.com/golang/lint.git lint

安裝:

go install golang.org/x/lint/golint

在bin下面會出現golint.exe
————————————————
版權聲明:本文為CSDN博主「愛喝水的社長」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/xiazhipeng1000/article/details/109584712

 

 

一些問題

1 如果clone失敗多獲取幾次就好了

2 報錯“

golang.org/x/tools/cmd/guru
tools\go\internal\cgo\cgo.go:67:2: cannot find package "golang.org/x/sys/execabs" in any of:


執行下面命令

git clone https://github.com/golang/sys.git

 

 

3 配置gopls插件

 

對於沒有成功安裝gopls(智能提示功能)的小伙伴,下面是具體的操作方式

進入gopath cd %GOPATH%,接着一次執行

go env -w GOPROXY=https://goproxy.io,direct
go env -w GO111MODULE=on
go get golang.org/x/tools/gopls@latest

結束記得關閉
go env -w GO111MODULE=off

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM