- 首先安装vscode
- git golang 都装好
- 在命令行输入如下命令
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-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
go get -u -v golang.org/x/tools/cmd/guru
-
golang.org/x/
一般会被墙,可以去github上先clone下来,一般对应在这个地址
https://github.com/golang - 拷贝到
src/golang.org/x/
目录下 - 继续
go get
或者go install
src文件夹下源码 :链接:https://pan.baidu.com/s/1BL2uaP9LKRbuvwShwiMTjw 密码:5d7b
bin文件夹二进制:链接:https://pan.baidu.com/s/1uZVSdHcprT2gQX8L8TG7MA 密码:4io5
二进制文件是win10 64位环境下的 - 在
.vscode
文件夹下新建launch.json
和setting.json
两个文件 launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceRoot}\\debug",
"env": {},
"args": []
}
]
}
setting.json
{
"files.autoSave": "onFocusChange",
"go.buildOnSave": true,
"go.lintOnSave": true,
"go.vetOnSave": true,
"go.buildTags": "",
"go.buildFlags": [],
"go.lintFlags": [],
"go.vetFlags": [],
"go.coverOnSave": false,
"go.useCodeSnippetsOnFunctionSuggest": false,
"go.formatOnSave": true,
"go.formatTool": "goreturns",
"go.goroot": "$GOROOT",
"go.gopath": "$GOPATH",
"go.gocodeAutoBuild": true
}
或者使用Vscode提供的插件的默认配置,会出现某些bin安装失败的情况,操作同上。就可以有完美的golang开发环境了。