Merge pull request 'Defer DB.Close() sur chaque DataClient' (#22) from fix/defer-dataclient-close into main
Reviewed-on: #22
This commit is contained in:
commit
ecb30b2d9b
2 changed files with 3 additions and 2 deletions
|
@ -59,14 +59,13 @@ var apiCmd = &cobra.Command{
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Could not establish database connection.\n Error: %s\n", err)
|
log.Fatalf("Could not establish database connection.\n Error: %s\n", err)
|
||||||
}
|
}
|
||||||
|
defer client.DB.Close()
|
||||||
|
|
||||||
err = client.DB.Ping()
|
err = client.DB.Ping()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Database was supposed to be ready but Ping() failed.\n Error: %s\n", err)
|
log.Fatalf("Database was supposed to be ready but Ping() failed.\n Error: %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
client.DB.Close()
|
|
||||||
|
|
||||||
e.Logger.Fatal(e.Start(fmt.Sprintf(":%d", apiPort)))
|
e.Logger.Fatal(e.Start(fmt.Sprintf(":%d", apiPort)))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ func PostMembres(c echo.Context) error {
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
defer client.DB.Close()
|
||||||
|
|
||||||
var membres []models.Membre
|
var membres []models.Membre
|
||||||
|
|
||||||
|
@ -56,6 +57,7 @@ func PostProgrammes(c echo.Context) error {
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
defer client.DB.Close()
|
||||||
|
|
||||||
var programmes []models.Programme
|
var programmes []models.Programme
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue