Help with installing spurtcms: panic: runtime error: invalid memory address or nil pointer dereference

Hello!
During the installation of spurtcms, when running the command: “go run main.go” the following error occurs:

mkdir logs: file exists
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x6ee952]

goroutine 1 [running]:
gorm.io/gorm.(*DB).getInstance(0x90?)
	/home/rustem/go/pkg/mod/gorm.io/gorm@v1.25.9/gorm.go:399 +0x12
gorm.io/gorm.(*DB).Table(0x0?, {0x128e6eb, 0x14}, {0x0, 0x0, 0x0})
	/home/rustem/go/pkg/mod/gorm.io/gorm@v1.25.9/chainable_api.go:65 +0x45
spurt-cms/models.GetGeneralSettings()
	/home/rustem/spurtcms-admin/models/general-setting.go:20 +0x45
spurt-cms/controllers.SetInitialGeneralValues()
	/home/rustem/spurtcms-admin/controllers/general-settings.go:16 +0x45
spurt-cms/controllers.init.0()
	/home/rustem/spurtcms-admin/controllers/authcontroller.go:34 +0x6d
exit status 2

I have go version go1.23.1 linux/amd64 installed.
The Ubuntu 24 operating system.

Please help me solve this problem.
It may seem easy for someone, but since I am a beginner, it causes difficulties for me.
Thanks!

It seems that you are using a variable with nil value. You could have forgotten to assign a value to that variable.

I guess that you have some kind of struct with a few variables.

type Store struct {
    db *sql.DB
}
func main() {
    store := &Store{}
    err := store.db.Ping() // here you are getting error, because 
    // you use variable that has nil value. 

    store.db = .... // u have to assign a value to it
}

In general you should read the documentation carefully and after this you can make an issue or an suggestion on github, describe in detail what you did and the error. The developers will be thankful about your input and fix it for everyone.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.