Defer DB.Close() sur chaque DataClient
This commit is contained in:
parent
e492e82960
commit
3870ef42dd
2 changed files with 3 additions and 2 deletions
|
@ -59,14 +59,13 @@ var apiCmd = &cobra.Command{
|
|||
if err != nil {
|
||||
log.Fatalf("Could not establish database connection.\n Error: %s\n", err)
|
||||
}
|
||||
defer client.DB.Close()
|
||||
|
||||
err = client.DB.Ping()
|
||||
if err != nil {
|
||||
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)))
|
||||
},
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ func PostMembres(c echo.Context) error {
|
|||
"error": err.Error(),
|
||||
})
|
||||
}
|
||||
defer client.DB.Close()
|
||||
|
||||
var membres []models.Membre
|
||||
|
||||
|
@ -56,6 +57,7 @@ func PostProgrammes(c echo.Context) error {
|
|||
"error": err.Error(),
|
||||
})
|
||||
}
|
||||
defer client.DB.Close()
|
||||
|
||||
var programmes []models.Programme
|
||||
|
||||
|
|
Reference in a new issue