第一步: 安装最新版的Golang
第二步: 安装VS Code 的 Go 语言插件
第三步: 接受VS Code 的推荐安装
- 这里应该会一个都安装不上, 因为Golang 官网是被墙的
- 使用 git bash 设置 代理.
export http_proxy=http://127.0.0.1:1080
export https_proxy=https://127.0.0.1:1080
- 手动安装需要的golib
go get -v -u github.com/mdempsky/gocode gocode
go get -v -u github.com/uudashr/gopkgs/cmd/gopkgs gopkgs
go get -v -u github.com/ramya-rao-a/go-outline go-outline
go get -v -u github.com/acroca/go-symbols go-symbols
go get -v -u golang.org/x/tools/cmd/guru guru
go get -v -u golang.org/x/tools/cmd/gorename gorename
go get -v -u github.com/derekparker/delve/cmd/dlv dlv
go get -v -u github.com/stamblerre/gocod gocode-gomod
go get -v -u github.com/rogpeppe/godef godef
go get -v -u github.com/ianthehat/godef godef-gomod
go get -v -u github.com/sqs/goreturns goreturns
go get -v -u golang.org/x/lint/golint golint
- 手动 build
go build -o %GOPATH%\\bin\\gocode.exe github.com/mdempsky/gocode
go build -o %GOPATH%\\bin\\gopkgs.exe github.com/uudashr/gopkgs/cmd/gopkgs%
go build -o %GOPATH%\\bin\\go-outline.exe github.com/ramya-rao-a/go-outline%
go build -o %GOPATH%\\bin\\go-symbols.exe github.com/acroca/go-symbols%
go build -o %GOPATH%\\bin\\guru.exe golang.org/x/tools/cmd/guru%
go build -o %GOPATH%\\bin\\gorename.exe golang.org/x/tools/cmd/gorename%
go build -o %GOPATH%\\bin\\dlv.exe github.com/derekparker/delve/cmd/dlv%
go build -o %GOPATH%\\bin\\gocode-gomod.exe github.com/stamblerre/gocode
go build -o %GOPATH%\\bin\\godef.exe github.com/rogpeppe/godef
go build -o %GOPATH%\\bin\\godef-gomod.exe github.com/ianthehat/godef
go build -o %GOPATH%\\bin\\goreturns.exe github.com/sqs/goreturns%
go build -o %GOPATH%\\bin\\golint.exe golang.org/x/lint/golint
- 手动将所有的.exe文件放入%Goroot%\bin 文件夹下, 至少包含以下几种
dlv
gocode
gocode-gomod
godef
godef-gomod
golint
go-outline
gopkgs
gorename
goreturns
go-symbols
guru
配置 VS Code
- 使用文件夹配置, 在.vscode文件夹下新建settings.json
{
"go.buildOnSave": "package",
"go.lintOnSave": "package",
"go.vetOnSave": "package",
"go.coverOnSave": false,
"go.formatTool": "goreturns",
"go.goroot": "C://Go",
"go.gopath": "C://go",
"go.gocodeAutoBuild": true
}
收尾, 删除临时性文件
有疑问加站长微信联系(非本文作者)