-
安装
go.msi
-
配置
GOPATH
先在本地建立文件夹src 存放源代码 pkg 编译过后生成的包文件 bin 编译后生产的可执行文件和go相关的工具 把此目录加入Path环境变量下方便go的使用
在环境变量中添加该目录路径
注意用户环境中是否有相同的配置
- vs code中配置
配置git
路径
"git.path": "D:/Program Files/Git/cmd/git.exe",
// go
"go.buildOnSave": "workspace",
"go.lintOnSave": "package",
"go.vetOnSave": "package",
"go.buildTags": "",
"go.buildFlags": [],
"go.lintFlags": [],
"go.vetFlags": [],
"go.coverOnSave": false,
"go.useCodeSnippetsOnFunctionSuggest": false,
"go.formatOnSave": true,
"go.formatTool": "goreturns",
"go.goroot": "C:\\Go",
"go.gopath": "F:\\GoPath",
"go.gocodeAutoBuild": false,
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"workbench.iconTheme": "vscode-icons",
注意用 斜杠/
或 反斜杠\\
-
go env
查看配置 -
添加 go 的 tools
先新建文件夹
再切换到x
目录下,下载插件包
git clone https://github.com/golang/tools.git tools
然后下载需要的模块
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/josharian/impl
go install github.com/rogpeppe/godef
go install github.com/sqs/goreturns
go install github.com/golang/lint/golint
go install github.com/cweill/gotests/gotests
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/josharian/impl
go install github.com/rogpeppe/godef
go install github.com/sqs/goreturns
go install github.com/cweill/gotests/gotests