vs code 配置 golang 环境
第一步: windows安装GoLang
直接 下载 然后一直点 步骤省略
安装后验证 go version
要注意,GoLang的环境变量 GOPATH 文件夹提前创建好
第二步安装vs code
步骤省略
第三步 安装插件
打开vs code 然后 Ctrl+Shift+P 输入 install
完成后
文件夹下创建如下这三个文件夹
然后用cmd命令下载插件
go get -u -
v
github.com
/nsf/gocode
go get -u -
v
github.com
/rogpeppe/godef
go get -u -
v
github.com
/golang/lint/golint
go get -u -
v
github.com
/lukehoban/go-find-references
go get -u -
v
github.com
/lukehoban/go-outline
go get -u -
v
sourcegraph.com
/sqs/goreturns
go get -u -
v
golang.org
/x/tools/cmd/gorename
go get -u -
v
github.com
/tpng/gopkgs
go get -u -
v
github.com
/newhook/go-symbols
有几个插件被墙了 下载会错误
继续:
md %GOPATH%\src\github.com\golang
cd
%GOPATH%\src\github.com\golang
git clone https:
//github
.com
/golang/tools
.git tools
md %GOPATH%\src\golang.org\x\tools
xcopy
/s
/e
%GOPATH%\src\github.com\golang\tools
之后再执行:
go
install
github.com
/nsf/gocode
go
install
sourcegraph.com
/sqs/goreturns
go
install
github.com
/golang/lint/golint
go
install
github.com
/newhook/go-symbols
go
install
golang.org
/x/tools/cmd/guru
go
install
golang.org
/x/tools/cmd/gorename
go
install
github.com
/rogpeppe/godef
go
install
github.com
/lukehoban/go-outline
继续在vscode中
文件--首选项--设置 如图:
方便复制
{
"files.autoSave": "onFocusChange",
"go.buildOnSave": true,
"go.lintOnSave": true,
"go.vetOnSave": true,
"go.buildTags": "",
"go.buildFlags": [],
"go.lintFlags": [],
"go.vetFlags": [],
"go.useCodeSnippetsOnFunctionSuggest": false,
"go.formatOnSave": false,
"go.formatTool": "goreturns",
"go.goroot": "D:\\Go",
"go.gopath": "D:\\GoMyNew"
}
这样 环境就可以搭建好了