feat: use pgxpool in backend
All checks were successful
Build and Deploy Go App / build (push) Successful in 17m56s
Build and Deploy Go App / deploy (push) Successful in 3m42s

This commit is contained in:
nihonium 2025-11-18 15:39:24 +03:00
parent a9391c18b9
commit c0be58ba07
Signed by: nihonium
GPG key ID: 0251623741027CFC
2 changed files with 7 additions and 6 deletions

View file

@ -13,7 +13,7 @@ import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/pelletier/go-toml/v2"
)
@ -31,17 +31,17 @@ func main() {
// log.Fatalf("Failed to init config: %v\n", err)
// }
conn, err := pgx.Connect(context.Background(), os.Getenv("DATABASE_URL"))
pool, err := pgxpool.New(context.Background(), os.Getenv("DATABASE_URL"))
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to connect to database: %v\n", err)
os.Exit(1)
}
defer conn.Close(context.Background())
defer pool.Close()
r := gin.Default()
queries := sqlc.New(conn)
queries := sqlc.New(pool)
server := handlers.NewServer(queries)
// r.LoadHTMLGlob("templates/*")