go环境搭建开发工具安装配置

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
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值