当前位置:网站首页>go导入自建包
go导入自建包
2022-07-01 01:10:00 【qq_45691577】
1.go mod init 你的mudlename
(在项目文件夹之下执行命令)
比如我这里的包名是wjj/ginessetial
2.创建自己的包,并在main.go中引入
新建一个文件夹,比如这里是DB

DB中创建的go文件包的名称为db

那么当你在main.go中向要调用DB文件夹下的某个函数(如此处为Initdb),该怎么引入对应的包呢?
在main.go中,引入的时候要这么写:
import "你的modulename/项目根目录/函数所在文件夹"
例如我要引入DB目录下的包,就是这样的:

边栏推荐
- QT web development - VIDEO - Notes
- Unknown database connection database error
- 1500w播放下还藏着什么热点?B站2个未来趋势你不得错过
- Lecun, a Turing Award winner, pointed out that the future of AI lies in self-learning, and the company has embarked on the journey
- Opencv -- Notes
- 【agora】用户管理
- 数学知识:求组合数 IV—求组合数
- org. redisson. client. Redisresponsetimeoutexception: redis server response timeout (3000 ms) error resolution
- 7-2 拼题A打卡奖励 dp
- 使用 C# 创造 ASCII 艺术
猜你喜欢
随机推荐
gin 配置文件
Factory + strategy mode
AS400 API 从零到一的整个历程
【动态规划】路径dp:931. Minimum Falling Path Sum
[dynamic planning] path dp:931 Minimum Falling Path Sum
C # customize and dynamically switch cursor
AS400 大廠面試
迪赛智慧数——其他图表(平行坐标图):2021年应届专业就业情况
laravel 事件 & 监听
Ks009 implementation of pet management system based on SSH
关于白盒测试,这些技巧你得游刃有余~
微生物安全与健康,什么是生物处理?
6月第4周榜单丨飞瓜数据UP主成长排行榜(哔哩哔哩平台)发布!
flutter报错 -- The argument type ‘Function‘ can‘t be assigned to the parameter type ‘void Function()?‘
那些一门心思研究自动化测试的人,后来怎样了?
Unknown database connection database error
工作八年的程序员,却拿着毕业三年的工资,再不开窍就真晚了...
软件测试的可持续发展,必须要学会敲代码?
[JS adds attributes to elements: setAttribute; classlist.remove; classlist.add;]
Mathematical knowledge: 01 sequence satisfying conditions - find combinatorial number








