在用goland来连接数据库时会出现一个问题。导包不成功可以通过以下方法来解决问题
在这里插入图片描述
在goland的终端输入

go get github.com/go-sql-driver/mysql

在输入后也许会报这样的错误

go get: 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: connect
ex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because conn
ected host has failed to respond.

这是因为无法对外网进行访问,可以通过输入一下命令进入代理网站进行访问

go env -w GOPROXY=https://goproxy.cn,direct

然后在输入上述命令就可以执行了

go get github.com/go-sql-driver/mysql

然后就会发现文件已经导入
在这里插入图片描述

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐