当前位置:网站首页>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目录下的包,就是这样的:

边栏推荐
- Strictmode jamming and leakage detection -strictmode principle (2)
- 那些一门心思研究自动化测试的人,后来怎样了?
- 物业怎么发短信通知给业主?
- flutter报错 -- The argument type ‘Function‘ can‘t be assigned to the parameter type ‘void Function()?‘
- Complete software development process
- QT web development - VIDEO - Notes
- Understanding and application of Qt5 layout in creation
- 【agora】用户管理
- Use strictmode strictmode principle (1)
- neo4j安装、运行以及项目的构建和功能实现
猜你喜欢

小程序中实现excel数据的批量导入

Compile and install oh my Zsh

关于白盒测试,这些技巧你得游刃有余~

3500 word summary: a complete set of skills that a qualified software testing engineer needs to master

农产品换房?“变相”购房补贴!

视频教程 | 长安链推出系列视频教程合集(入门)

6月第4周榜单丨飞瓜数据UP主成长排行榜(哔哩哔哩平台)发布!

PHP crawls data through third-party plug-ins

PHP通过第三方插件爬取数据

图灵奖得主LeCun指明AI未来的出路在于自主学习,这家公司已踏上征途
随机推荐
农产品换房?“变相”购房补贴!
Understanding and application of Qt5 layout in creation
远程办公如何保持高效协同,实现项目稳定增长 |社区征文
【JS给元素添加属性:setAttribute;classList.remove;classList.add;】
【栈】921. Minimum Add to Make Parentheses Valid
直播商城源码,实现左右联动商品分类页面
[deepin] common sets
【Content-Type请求头的内容】
微生物健康,食品微生物检测为什么很重要
org.redisson.client.RedisResponseTimeoutException: Redis server response timeout (3000 ms)错误解决
Log logrus third party library usage
org. redisson. client. Redisresponsetimeoutexception: redis server response timeout (3000 ms) error resolution
数据探索电商平台用户行为流失分析
工厂+策略模式
Necessary tools for testing - postman practical tutorial
Compile and install oh my Zsh
AS400 大廠面試
短视频平台开发,依靠DrawerLayout实现侧滑菜单效果
Check the disk usage of MySQL database
For the sustainable development of software testing, we must learn to knock code?