下载地址: https://studygolang.com/dl
1、下载安装包 gox.x.windows-amd64.msi,安装在D:\Go
2、设置环境变量
- 设置GOROOT为 D:\Go\,此为go安装目录
- 添加path为 %GOROOT%/bin
- 设置GOPATH为E:\go,此为go工作空间,如果不生效,在用户的环境变量中设置
3、在GOPATH 目录下添加文件夹 src、bin、pkg
4、打开cmd查看是否设置正确 ,命令go env
5、下载VS Code,下载go插件 Go for Visual Studio Code
6、调试工具delve下载,注意需要安装git并配置好环境变量
- 打开cmd ,执行命令 go get github.com/derekparker/delve/cmd/dlv
二、Mac 环境
1、vs code 插件失败解决
1.1、前提终端能赛先生上网,curl www.google.com 有结果,还有版本问题也会导致插件不成功,测试go版本为1.11.1
$ mkdir -p $GOPATH/src/golang.org/x
$ cd $GOPATH/src/golang.org/x
$ git clone https://github.com/golang/tools.git
$ git clone https://github.com/golang/lint.git
$ go get golang.org/x/lint/golint
```
1.2、进vs code ,会提示 instaling xxxx FAILED 就在终端依次执行
```shell
$ go get golang.org/x/lint/golint
$ go get github.com/mdempsky/gocode
$ go get github.com/ramya-rao-a/go-outline
$ go get github.com/acroca/go-symbols
$ go get golang.org/x/tools/cmd/guru
$ go get golang.org/x/tools/cmd/gorename
1.3、还有坑...
如果出现
package golang.org/x/tools/go/packages: golang.org/x/tools is a custom import path for https://go.googlesource.com/tools, but /Users/nidazhong/projects/go_project/src/golang.org/x/tools is checked out from https://github.com/golang/tools.git
/Users/nidazhong/projects/go_project/src/golang.org/x/tools go get github.com/stamblerre/gocode