From 75fda8d9521f106329ac74eef16737b2dde55091 Mon Sep 17 00:00:00 2001 From: alvanrahimli Date: Sun, 15 Aug 2021 12:59:21 +0400 Subject: [PATCH] General Refactoring --- database.go | 18 +++++++++++++----- server.go | 10 ---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/database.go b/database.go index 64741e0..648d833 100644 --- a/database.go +++ b/database.go @@ -1,8 +1,16 @@ package main -func InitializeDb() { - //setupCommand := ` - // CREATE DATABASE DotsDb; - // CREATE TABLE - //` +import ( + "database/sql" + "log" + "os" +) + +func getDbInstance() *sql.DB { + db, dbErr := sql.Open("sqlite3", os.Getenv("DB_PATH")) + if dbErr != nil { + log.Fatal(dbErr) + } + + return db } diff --git a/server.go b/server.go index 14111be..694c008 100644 --- a/server.go +++ b/server.go @@ -1,7 +1,6 @@ package main import ( - "database/sql" "fmt" "github.com/gorilla/mux" _ "github.com/mattn/go-sqlite3" @@ -47,12 +46,3 @@ func main() { log.Fatal(err) } } - -func getDbInstance() *sql.DB { - db, dbErr := sql.Open("sqlite3", os.Getenv("DB_PATH")) - if dbErr != nil { - log.Fatal(dbErr) - } - - return db -}