当前位置:网站首页>记一个gorm初始化的坑
记一个gorm初始化的坑
2022-08-02 02:12:00 【不是住在隔壁的老王】
跨文件初始化gorm的时候,如果提前声明db *gorm.DB后在gorm.open的时候是用 db,err:= gorm.open的话 后续会报错
错误代码为:
panic: runtime error: invalid memory address or nil pointer dereference
将db,err := gorm.open改为
var err error
db,err = gorm.open
错误解决

解决思路来自博客:
http://t.csdn.cn/IxS0o
边栏推荐
- Pinduoduo leverages the consumer expo to promote the upgrading of domestic agricultural products brands and keep pace with international high-quality agricultural products
- 2022-07-30 mysql8 executes slow SQL-Q17 analysis
- nacos startup error, the database has been configured, stand-alone startup
- LeetCode Review Diary: 34. Find the first and last position of an element in a sorted array
- Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021: Interpretation
- LeetCode刷题日记:LCP 03.机器人大冒险
- 2023年起,这些地区软考成绩低于45分也能拿证
- 软件测试 接口自动化测试 pytest框架封装 requests库 封装统一请求和多个基础路径处理 接口关联封装 测试用例写在yaml文件中 数据热加载(动态参数) 断言
- typescript30 - any type
- Project Background Technology Express
猜你喜欢

Data transfer at the data link layer

oracle查询扫描全表和走索引

【LeetCode每日一题】——103.二叉树的锯齿形层序遍历
A full set of common interview questions for software testing functional testing [open thinking questions] interview summary 4-3
![[LeetCode Daily Question] - 103. Zigzag Level Order Traversal of Binary Tree](/img/b9/35813ae2972375fa728e3c11fab5d3.png)
[LeetCode Daily Question] - 103. Zigzag Level Order Traversal of Binary Tree

The ultra-large-scale industrial practical semantic segmentation dataset PSSL and pre-training model are open source!

『网易实习』周记(一)

Yunhe Enmo: Let the value of the commercial database era continue to prosper in the openGauss ecosystem

【LeetCode每日一题】——654.最大二叉树

Personal blog system project test
随机推荐
¶Backtop 回到顶部 不生效
CodeTon Round 2 D. Magical Array 规律
typescript29-枚举类型的特点和原理
Redis 持久化 - RDB 与 AOF
Chengdu openGauss user group recruit!
『网易实习』周记(二)
手写一个博客平台~第一天
Electronic Manufacturing Warehouse Barcode Management System Solution
swift project, sqlcipher3 -> 4, cannot open legacy database is there a way to fix it
typescript33 - high-level overview of typescript
【LeetCode每日一题】——654.最大二叉树
typescript32-ts中的typeof
LeetCode Review Diary: 153. Find the Minimum Value in a Rotated Sort Array
NIO‘s Sword(牛客多校赛)
Handwriting a blogging platform ~ Day 3
Fundamentals of Cryptography: X.690 and Corresponding BER CER DER Encodings
拼多多借力消博会推动国内农产品品牌升级 看齐国际精品农货
MySQL优化策略
Day115.尚医通:后台用户管理:用户锁定解锁、详情、认证列表审批
C language inserted into the characters of simple exercises