From db1c213729fd1b9c1814546cce3c93defb396281 Mon Sep 17 00:00:00 2001 From: Giacomo Sanchietti Date: Wed, 18 Apr 2018 10:28:44 +0200 Subject: [PATCH] wax. move db init inside main method Avoid error: (sql: database is closed) --- wax/main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wax/main.go b/wax/main.go index 1b894c68c..cc18432db 100644 --- a/wax/main.go +++ b/wax/main.go @@ -44,10 +44,6 @@ func DefineAPI(router *gin.Engine) { corsConf.AllowMethods = configuration.Config.Cors.Methods router.Use(cors.New(corsConf)) - // init Database - db := database.Init() - defer db.Close() - health := router.Group("/health") health.GET("/check", methods.HealthCheck) @@ -94,6 +90,10 @@ func main() { flag.Parse() configuration.Init(ConfigFilePtr) + // init Database + db := database.Init() + defer db.Close() + // init routers router := gin.Default()