当前位置:网站首页>Remember a pit for gorm initialization
Remember a pit for gorm initialization
2022-08-02 02:15:00 【Not the old king who lives next door】
When initializing gorm across files, if db is used in gorm.open after db *gorm.DB is declared in advance, and err:= gorm.open, an error will be reported later
The error code is:
panic: runtime error: invalid memory address or nil pointer dereference
change db,err:=gorm.open to
var err error
db,err=gorm.open
error resolved

The solution comes from blog:
http://t.csdn.cn/IxS0o
边栏推荐
猜你喜欢
随机推荐
¶Backtop 回到顶部 不生效
LeetCode Brushing Diary: 74. Searching 2D Matrix
拼多多借力消博会推动国内农产品品牌升级 看齐国际精品农货
菜刀webshell特征分析
NIO‘s Sword(牛客多校赛)
Service discovery of kubernetes
Software testing Interface automation testing Pytest framework encapsulates requests library Encapsulates unified request and multiple base path processing Interface association encapsulation Test cas
乱七八糟的网站
messy website
Outsourcing worked for three years, it was abolished...
3. Bean scope and life cycle
Handwritten Blog Platform ~ Day Two
60 Feature Engineering Operations: Using Custom Aggregate Functions【Favorites】
【web】理解 Cookie 和 Session 机制
LeetCode Review Diary: 153. Find the Minimum Value in a Rotated Sort Array
2022河南青训联赛第(三)场
AWR分析报告问题求助:SQL如何可以从哪几个方面优化?
swift项目,sqlcipher3 -> 4,无法打开旧版数据库有办法解决吗
【LeetCode每日一题】——704.二分查找
[LeetCode Daily Question]——654. The largest binary tree




![[LeetCode Daily Question]——654. The largest binary tree](/img/05/0af1c6dc0085e253c0758c8da63e52.png)


