Files
go-sqlc-htmx/main.go
2025-06-12 13:12:20 +03:00

33 lines
628 B
Go

package main
import (
"database/sql"
"log"
"time"
_ "github.com/lib/pq"
"github.com/yourusername/go-sqlc-jwt/config"
"github.com/yourusername/go-sqlc-jwt/db"
r "github.com/yourusername/go-sqlc-jwt/routes"
)
func main() {
cfg := config.GetCfg()
dbConn, err := sql.Open("postgres", cfg.DB.DSN)
if err != nil {
log.Fatal("failed to connect to db:", err)
}
defer dbConn.Close()
// Configure database connection pool
dbConn.SetMaxOpenConns(25)
dbConn.SetMaxIdleConns(25)
dbConn.SetConnMaxLifetime(5 * time.Minute)
queries := db.New(dbConn)
router := r.MainRouter(queries)
log.Fatal(router.Run(":8080"))
}