some stuff from mac
This commit is contained in:
20
main.go
20
main.go
@@ -1,14 +1,32 @@
|
||||
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() {
|
||||
router := r.MainRouter()
|
||||
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"))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user