package main import ( "database/sql" _ "github.com/lib/pq" "log" ) var ( database *sql.DB ) func init() { connStr := "user=levyraati dbname=levyraati sslmode=disable" var err error database, err = sql.Open("postgres", connStr) if err != nil { log.Fatal(err) } _, err = database.Query("SELECT 1") if err != nil { log.Fatal(err) } } func getDb() *sql.DB { return database }