working sub

This commit is contained in:
2026-03-05 12:21:32 +03:00
parent 205d9cf8b0
commit 951f3ab482
6 changed files with 65 additions and 14 deletions

View File

@@ -2,15 +2,21 @@ package app
import (
"fmt"
"log"
"os"
"github.com/joho/godotenv"
_ "github.com/lib/pq"
"github.com/vinovest/sqlx"
)
import _ "github.com/lib/pq"
var db *sqlx.DB = nil
func init() {
if err := godotenv.Load(".env"); err != nil {
log.Println("Error loading .env file. If you use docker, then you can ignore this.")
}
if db == nil {
connectPsql()
}
@@ -33,6 +39,4 @@ func connectPsql() {
panic(err)
}
}
func ClosePsql() error {
return db.Close()
}
func ClosePsql() error { return db.Close() }