windows装置

下载安装

Go官网下载地址:https://golang.org/dl/

因为网络问题大家可能关上有些慢,或者下载失败。大家也能够从下边下载。
下载执行后大家间接一路下一步就行了。

配置环境变量

(win+pause关上设置)--> 高级设置 --> 高级 --> 环境变量

配置GOPATH;他是用来寄存你我的项目工程代码的中央。
而后将GOPATH 和 go装置的路劲配置到path中。

而后通过cmd执行go version查看版本,当看到版本后证实装置胜利。

创立工程目录

在咱们GOPATH中创立 bin pkg src

开发工具

go语言的开发工具有很多,这个依据集体的爱好进行抉择。vscode、goland 、IntelliJ + Go 插件、LiteIDE等都行。他就是一个工具不必太纠结。

vscode+go插件

mac和window装置一样的。去官网下载https://code.visualstudio.com/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.  gopkgs  go-outline  gotests  gomodifytags  impl  goplay  dlv  dlv-dap  staticcheck  goplsInstalling github.com/uudashr/gopkgs/v2/cmd/gopkgs@latest FAILED{ "killed": false, "code": 1, "signal": null, "cmd": "C:\\Program Files\\Go\\bin\\go.exe install -v github.com/uudashr/gopkgs/v2/cmd/gopkgs@latest", "stdout": "", "stderr": "go install: github.com/uudashr/gopkgs/v2/cmd/gopkgs@latest: module github.com/uudashr/gopkgs/v2/cmd/gopkgs: Get \"https://proxy.golang.org/github.com/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 github.com/ramya-rao-a/go-outline@latest FAILED{ "killed": false, "code": 1, "signal": null, "cmd": "C:\\Program Files\\Go\\bin\\go.exe install -v github.com/ramya-rao-a/go-outline@latest", "stdout": "", "stderr": "go install: github.com/ramya-rao-a/go-outline@latest: module github.com/ramya-rao-a/go-outline: Get \"https://proxy.golang.org/github.com/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 github.com/cweill/gotests/gotests@latest FAILED{ "killed": false, "code": 1, "signal": null, "cmd": "C:\\Program Files\\Go\\bin\\go.exe install -v github.com/cweill/gotests/gotests@latest", "stdout": "", "stderr": "go install: github.com/cweill/gotests/gotests@latest: module github.com/cweill/gotests/gotests: Get \"https://proxy.golang.org/github.com/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 github.com/fatih/gomodifytags@latest FAILED{ "killed": false, "code": 1, "signal": null, "cmd": "C:\\Program Files\\Go\\bin\\go.exe install -v github.com/fatih/gomodifytags@latest", "stdout": "", "stderr": "go install: github.com/fatih/gomodifytags@latest: module github.com/fatih/gomodifytags: Get \"https://proxy.golang.org/github.com/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 github.com/josharian/impl@latest FAILED{ "killed": false, "code": 1, "signal": null, "cmd": "C:\\Program Files\\Go\\bin\\go.exe install -v github.com/josharian/impl@latest", "stdout": "", "stderr": "go install: github.com/josharian/impl@latest: module github.com/josharian/impl: Get \"https://proxy.golang.org/github.com/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