diff options
author | Emile <hanemile@protonmail.com> | 2019-10-19 00:55:14 +0200 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2019-10-19 00:55:14 +0200 |
commit | b674fc35ad25e90db13f1f5a7ae8eb08232782a7 (patch) | |
tree | d63f482a2c435a6572cd35b9fd3021058393e854 | |
parent | 4d84bdadaf691a7258f18f0055f3da1d28bbf617 (diff) |
setting up the database connection correctly
-rw-r--r-- | src/main.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main.go b/src/main.go index 38f254c..4af5cc4 100644 --- a/src/main.go +++ b/src/main.go @@ -1,8 +1,8 @@ package main import ( + "database/sql" "flag" - "fmt" "log" "net/http" "os" @@ -11,6 +11,10 @@ import ( _ "github.com/lib/pq" ) +var ( + db *sql.DB +) + func main() { // Set up flags log.Println("Setting up components") @@ -22,9 +26,7 @@ func main() { httpServer := setupHTTPServer() // Set up the DB connection - db := setupDatabase() - name := getName(db) - fmt.Println(name) + db = setupDatabase() // React to system signals signalChannel := make(chan os.Signal, 1) |