当前位置:网站首页>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
边栏推荐
- The principle and code implementation of intelligent follower robot in the actual combat of innovative projects
- How to adjust the cross cursor too small, CAD dream drawing calculation skills
- Power button 1374. Generate each character string is an odd number
- LeetCode 213. Robbery II (2022.08.01)
- BI-SQL丨WHILE
- Constructor instance method inheritance of typescript37-class (extends)
- Redis 持久化 - RDB 与 AOF
- 3. Bean scope and life cycle
- LeetCode Review Diary: 153. Find the Minimum Value in a Rotated Sort Array
- ALCCIKERS Shane 20191114
猜你喜欢

『网易实习』周记(三)

雇用WordPress开发人员:4个实用的方法

The principle and code implementation of intelligent follower robot in the actual combat of innovative projects

Entry name 'org/apache/commons/codec/language/bm/gen_approx_greeklatin.txt' collided
![[ORB_SLAM2] void Frame::ComputeImageBounds(const cv::Mat & imLeft)](/img/ed/ffced88c9d23c20ccf380494051381.jpg)
[ORB_SLAM2] void Frame::ComputeImageBounds(const cv::Mat & imLeft)

2022-07-30 mysql8 executes slow SQL-Q17 analysis

【Unity入门计划】2D Game Kit:初步了解2D游戏组成

Personal blog system project test

Handwritten Blog Platform ~ Day Two

Hash collisions and consistent hashing
随机推荐
Handwritten Blog Platform ~ Day Two
The failure to create a role in Dahua Westward Journey has been solved
2022 Henan Youth Training League Game (3)
Force buckle, 752-open turntable lock
[LeetCode Daily Question]——654. The largest binary tree
Golang分布式应用之定时任务
LeetCode刷题日记:74. 搜索二维矩阵
Redis Subscription and Redis Stream
垃圾回收器CMS和G1
项目后台技术Express
MySQL optimization strategy
to-be-read list
十字光标太小怎么调节、CAD梦想画图算量技巧
Handwriting a blogging platform ~ the first day
Win Go开发包安装配置、GoLand配置
Reflex WMS Intermediate Series 7: What should I do if I want to cancel the picking of an HD that has finished picking but has not yet been loaded?
Redis for distributed applications in Golang
Constructor instance method of typescript36-class
2022-08-01 Reflection
哈希冲突和一致性哈希