go导入“github.com/go-sql-driver/mysql“连接失败错误解决

Hey,我是寅贝勒,后端开发一枚😜,欢迎来我的个人网站 www.ly-zone.cloud 一起学习交流~

在使用golang连接mysql数据库时需要用到go的数据库连接驱动

github.com/go-sql-driver/mysql

  • 首先需要在golang的终端输入
go get -u github.com/go-sql-driver/mysql

可能会出现如下错误
在这里插入图片描述

PS E:\Go\practice\PRO1> go get -u github.com/go-sql-driver/mysql
go: module github.com/go-sql-driver/mysql: Get "https://proxy.golang.org/github.com/go-sql-driver/mysql/@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.
  • 这是因为无法对外网进行访问(开了VPN也不行),可以通过输入一下命令进入代理网站进行访问
go env -w GOPROXY=https://goproxy.cn,direct
  • 该结果无返回,然后再输入上述命令
go get -u github.com/go-sql-driver/mysql
  • 可以看到已经安装的版本号了
PS E:\Go\practice\PRO1> go get -u github.com/go-sql-driver/mysql   
go: downloading github.com/go-sql-driver/mysql v1.6.0
go: added github.com/go-sql-driver/mysql v1.6.0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

寅贝勒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值