windows安装
下载安装
Go官网下载地址:/dl/
由于网络问题大家可能打开有些慢,或者下载失败。大家也可以从下边下载。
下载执行后大家直接一路下一步就行了。
配置环境变量
(win+pause打开设置)–> 高级设置 --> 高级 --> 环境变量
配置GOPATH;他是用来存放你项目工程代码的地方。
然后将GOPATH 和 go安装的路劲配置到path中。
然后通过cmd执行go version查看版本,当看到版本后证明安装成功。
创建工程目录
在我们GOPATH中创建 bin pkg src
开发工具
go语言的开发工具有很多,这个根据个人的喜好进行选择。vscode、goland 、IntelliJ + Go 插件、LiteIDE等都行。他就是一个工具不用太纠结。
vscode+go插件
mac和window安装一样的。去官网下载/download
在vscode中搜索go,然后安装。为了方便使用你可以先安装一个中文插件。
安装成功后在安装go语言开发工具安装包(代码提示,代码自动补全等功能)。
shift+ctrl+p 然后输入go:install选择Go:Install/Update Tools
全选,然后安装。
安装问题解决
如果安装过程中显示如下无法安装。
Tools environment: GOPATH=C:\workspace\goprojectInstalling 10 tools at C:\workspace\goproject\bin in module mode.gopkgsgo-outlinegotestsgomodifytagsimplgoplaydlvdlv-dapstaticcheckgoplsInstalling /uudashr/gopkgs/v2/cmd/gopkgs@latest FAILED{"killed": false,"code": 1,"signal": null,"cmd": "C:\\Program Files\\Go\\bin\\go.exe install -v /uudashr/gopkgs/v2/cmd/gopkgs@latest","stdout": "","stderr": "go install: /uudashr/gopkgs/v2/cmd/gopkgs@latest: module /uudashr/gopkgs/v2/cmd/gopkgs: Get \"//uudashr/gopkgs/v2/cmd/gopkgs/@v/list\": dial tcp 172.217.27.145:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.\n"}Installing /ramya-rao-a/go-outline@latest FAILED{"killed": false,"code": 1,"signal": null,"cmd": "C:\\Program Files\\Go\\bin\\go.exe install -v /ramya-rao-a/go-outline@latest","stdout": "","stderr": "go install: /ramya-rao-a/go-outline@latest: module /ramya-rao-a/go-outline: Get \"//ramya-rao-a/go-outline/@v/list\": dial tcp 172.217.27.145:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.\n"}Installing /cweill/gotests/gotests@latest FAILED{"killed": false,"code": 1,"signal": null,"cmd": "C:\\Program Files\\Go\\bin\\go.exe install -v /cweill/gotests/gotests@latest","stdout": "","stderr": "go install: /cweill/gotests/gotests@latest: module /cweill/gotests/gotests: Get \"//cweill/gotests/gotests/@v/list\": dial tcp 172.217.27.145:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.\n"}Installing /fatih/gomodifytags@latest FAILED{"killed": false,"code": 1,"signal": null,"cmd": "C:\\Program Files\\Go\\bin\\go.exe install -v /fatih/gomodifytags@latest","stdout": "","stderr": "go install: /fatih/gomodifytags@latest: module /fatih/gomodifytags: Get \"//fatih/gomodifytags/@v/list\": dial tcp 172.217.27.145:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.\n"}Installing /josharian/impl@latest FAILED{"killed": false,"code": 1,"signal": null,"cmd": "C:\\Program Files\\Go\\bin\\go.exe install -v /josharian/impl@latest","stdout": "","stderr": "go install: /josharian/impl@latest: module /josharian/impl: Get \"//josharian/impl/@v/list\": dial tcp 142.251.42.241:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.\n"}
原因是网络问题。懂得都懂。我们只需配置一下国内的代理重新下载安装一下插件就好了。
go env -w GO111MODULE=ongo env -w GOPROXY=https://goproxy.io,direct