Upgraded Go version and the version of all dependencies. Fixed som more bugs.

This commit is contained in:
2024-05-18 13:11:15 +02:00
parent a863702b22
commit 59f1e2c75c
11 changed files with 227 additions and 1111 deletions

View File

@@ -3,11 +3,11 @@ package db
import (
"context"
"fmt"
"github.com/jackc/pgx/v4/pgxpool"
"github.com/jackc/pgx/v5"
"os"
)
var pool *pgxpool.Pool
var pool *pgx.Conn
func InitDB(host string, port int, user string, password string, dbname string) {
@@ -18,7 +18,7 @@ func InitDB(host string, port int, user string, password string, dbname string)
fmt.Println(psqlInfo)
var err error
pool, err = pgxpool.Connect(context.Background(), psqlInfo)
pool, err = pgx.Connect(context.Background(), psqlInfo)
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Unable to connect to database: %v\n", err)
os.Exit(1)
@@ -30,11 +30,15 @@ func InitDB(host string, port int, user string, password string, dbname string)
_, _ = fmt.Fprintf(os.Stderr, "QueryRow failed: %v\n", err)
os.Exit(1)
}
Testf()
fmt.Println(success)
}
func CloseDb() {
pool.Close()
err := pool.Close(context.Background())
if err != nil {
return
}
}
func Testf() {