共计 3652 个字符,预计需要花费 10 分钟才能阅读完成。
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\goproject
Installing 10 tools at C:\workspace\goproject\bin in module mode.
gopkgs
go-outline
gotests
gomodifytags
impl
goplay
dlv
dlv-dap
staticcheck
gopls
Installing 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=on
go env -w GOPROXY=https://goproxy.io,direct
正文完