π Contents
What are we building
Go
Express and Fiber
Let's Get Started With APIs
Let's create an endpoint
Go modules
Setup E...
For further actions, you may consider blocking this person and/or reporting abuse
First of all thank you for this amazing tutorial. I am a newbie in Golang language and i must say i am loving the experience so far. However on completion of this tutorial i am getting this error. If anyone could help me decode, i will appreciate.
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x28 pc=0xe56458]
goroutine 7 [running]:
gorm.io/gorm.(*DB).getInstance(0x167e7f70598)
C:/Users/BENSON OPISA/go/pkg/mod/gorm.io/gorm@v1.23.1/gorm.go:363 +0x18
gorm.io/gorm.(*DB).Find(0x167ed27dfe0, {0x12a7180, 0xc00009f4a0}, {0x0, 0x0, 0x0})
C:/Users/BENSON OPISA/go/pkg/mod/gorm.io/gorm@v1.23.1/finisher_api.go:159 +0x45
github.com/bensonopisa/notes-app/internal/handlers/note.GetNotes(0xc000428000)
D:/projects/golang/notes-app/internal/handlers/note/note.go:20 +0x69
github.com/gofiber/fiber/v2.(*App).next(0xc0000023c0, 0xc000428000)
C:/Users/BENSON OPISA/go/pkg/mod/github.com/gofiber/fiber/v2@v2.27.0/router.go:132 +0x1d8
This is thrown on the line db.Find(¬es) on the getNotes Function on notehandler package.
Sorry for the late reply. Seems like you are trying to access an uninitiated variable or nil value. Can you check if you are doing something different?
Great and many thanks for the detail explanation, its really help.
Just curious about folder structure, why not naming it "handlers/note.go" instead of handlers/noteHandlers.go or routes/noteRoutes.go.
Thanks man! Glad you liked it.
If you mean that why we did not use
handlers/noteHandlers.go
. The reason for this would be when we add more handlers, it would becomehandlers/noteHandlers.go
andhandlers/userHandlers.go
. It would be multiple packages inside the same folder which go does not like a lot.I hope I understood your question.
One of the best Fiber tutorial, I would like to know is it possible to use basic auth with gotemplates engine? I can't find inputs for this scenario.
Hi,
I am getting unexpected fault address 0xed9497c2d
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0xed9497c2d pc=0x4f8f6a]
when trying to return from getnotes
return ctx.JSON(fiber.Map{"status": http.StatusOK, "message": "notes found", "data": notes}), when returing null its working, and also when returning a hardcoded struct its working, but its breaking when returning the data returned from db, any idea why..
Never mind, seems like an issue in the latest version of fiber, can be fixed by
app := fiber.New(fiber.Config{
JSONEncoder: json.Marshal,
JSONDecoder: json.Unmarshal,
})
nice info, good tutorial..
First I saw basic tutorial at youtube.com/playlist?list=PLs1BaES... and then i implemented code using this blog. @percoguru you made my day. Thank you So much.. keep writing
Wow! This is such a well written tutorial! Iβve been writing Express CRUD apps for years, but Iβve just started my Go journey. So happy to have stumbled across this gem! Keep up the great work!
Thanks a lot!!
Thank you! Nice tutorial
Thank you :)