安装golang、git
golang官网下载Go语言安装包,安装。默认在 C:\Go
官网下载git,安装。默认在C:\Program Files\Git
配置环境变量
新建 GOBIN 值为 工作目录\bin (以后存的的是编译好的可执行文件)
新建 GOPATH 值为 工作目录(go编译时严格按照设置的工作目录中查找程序,编译)
Path 中新建 值为 %GOPATH%\bin
默认GOROOT 值为C:\Go\ (go官方语言安装的位置)
在 Path中 没有则新建 %GOROOT%\bin
在Path 中 新建 值为 C:\Program Files\Git\bin
vscode中配置
- 工作区设置 setting.json (.vscode\settings.json)
{
"workbench.colorTheme": "Visual Studio Dark",
"files.autoSave": "onFocusChange",
"go.buildOnSave": "off",
"go.lintOnSave" :"off",
"go.vetOnSave":"off",
"go.buildTags": "",
"go.buildFlags": [],
"go.lintFlags": [],
"go.vetFlags": [],
"go.coverOnSave": false,
"go.useCodeSnippetsOnFunctionSuggest":true,
"go.formatTool": "goreturns",
"go.goroot": "C:\\Go",
"go.gopath": "E:\\Project\\Go",
"go.gocodeAutoBuild": false
}
- 用户设置 setting.json (C:\Users\Xiaohu\AppData\Roaming\Code\User\settings.json)
{
"workbench.colorTheme": "Visual Studio Dark",
"files.autoSave": "onFocusChange",
"git.path": "C:/Program Files/Git/bin/git.exe"
}
创建目录E:\Project\Go\src\http://golang.org\x
git clone https://github.com/golang/tools.git
git clone https://github.com/golang/lint.git
go install golang.org/x/tools/cmd/goimports
安装所有插件
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 golang.org/x/tools/cmd/guru
go install golang.org/x/tools/cmd/gorename
go install github.com/derekparker/delve/cmd/dlv
go install github.com/stamblerre/gocode
go install github.com/rogpeppe/godef
go install github.com/ianthehat/godef
go install github.com/sqs/goreturns
go install golang.org/x/lint/golint1. 安装vscode、golang、git