Goland使用Go Modules创建/管理项目的操作
作者:deantzzz 时间:2024-04-30 10:03:02
创建项目
Location:新项目文件夹GOROOT:go 安装根目录Proxy:https://goproxy.io,direct
重要:https://goproxy.io是下载go包的代理地址,设置后可在国内正常下载go仓库/github的包。
创建一个go文件
创建了一个test.go
下载安装需要的包
这里演示安装mysql driver包:github.com/go-sql-driver/mysql
直接import显示找不到包,使用左下方命令行工具,安装mysql driver
使用go get 命令安装包
使用go get github.com/go-sql-driver/mysql安装mysql driver,安装成功后test.go中import的包变绿。
我已经安装过一次,第一次安装应该会在命令窗口出现一些信息。
补充:Goland 使用 go modules的TIPS
运行go mod tidy,报错:
go: golang.org/x/sys@v0.0.0-20180905080454-ebe1bf3edb33: unrecognized import path "golang.org/x/sys" (https fetch: Get https://golang.org/x/sys?go-get=1: dial tcp 216.239.37.1:443: c
onnectex: 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.)
go: error loading module requirements
原因是某些依赖在国内被墙了,这边可以设置一下proxy,就可以解决:
进入Goland的设置界面,File/Settings/Go/Go Module(vgo),设置一下Proxy为:https://goproxy.io。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持asp之家。如有错误或未考虑完全的地方,望不吝赐教。
来源:https://blog.csdn.net/qq_33398607/article/details/106099939
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python中整数的缓存机制讲解
python2.x实现人民币转大写人民币
使用Django框架中ORM系统实现对数据库数据增删改查
![](https://img.aspxhome.com/file/2023/0/115180_0s.png)
python频繁写入文件时提速的方法
tensorflow 大于某个值为1,小于为0的实例
pandas 使用insert插入一列
![](https://img.aspxhome.com/file/2023/2/133272_0s.jpg)
python计算列表元素与乘积详情
特征脸(Eigenface)理论基础之PCA主成分分析法
![](https://img.aspxhome.com/file/2023/2/134432_0s.png)
PHP+jQuery+Ajax实现多图片上传效果
![](https://img.aspxhome.com/file/2023/5/125765_0s.jpg)
如何快捷地实现分页显示功能?
Python使用matplotlib和pandas实现的画图操作【经典示例】
![](https://img.aspxhome.com/file/2023/8/75088_0s.png)
Python实现判断字符串中包含某个字符的判断函数示例
![](https://img.aspxhome.com/file/2023/1/115501_0s.png)
微信小程序实战之仿android fragment可滑动底部导航栏(4)
![](https://img.aspxhome.com/file/2023/2/139632_0s.gif)
ASP常见的保留字整理(变量与表名注意不能用)
Python可视化神器pyecharts之绘制箱形图
![](https://img.aspxhome.com/file/2023/6/102956_0s.png)
Python中字符串切片详解
![](https://img.aspxhome.com/file/2023/7/107607_0s.png)
Sql Server 查询性能优化之走出索引的误区分析
Matplotlib 3D 绘制小红花原理
![](https://img.aspxhome.com/file/2023/1/88001_0s.png)
Python利用FlashText算法实现替换字符串
![](https://img.aspxhome.com/file/2023/3/82563_0s.png)