I'm trying to build an API in Go lang with fiber(V2) and gorm.
When I try to set up the routes with this code :
main.go (package main) :
func setupRoutes(app *fiber.App) {
app.Get("/api/leads", lead.GetLeads)
app.Get("/api/leads/:id", lead.GetLead)
app.Post("/api/leads", lead.NewLead)
app.Delete("/api/leads/:id", lead.DeleteLead)
}
lead.go (package lead) :
func GetLeads(c *fiber.Ctx) {
db := database.BDConn
var leads []Lead
db.Find(&leads)
c.JSON(leads)
}
I got go the error : cannot use lead.GetLeads (value of type func(c *fiber.Ctx)) as func(*fiber.Ctx) error value in argument to app.Get
Do you know how to fix that ?