20 lines
326 B
Go
20 lines
326 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"context"
|
|
"github.com/jackc/pgx/v4/pgxpool"
|
|
"log"
|
|
)
|
|
|
|
var pool *pgxpool.Pool
|
|
|
|
func getDbPool() *pgxpool.Pool {
|
|
// Setup Database
|
|
pool, err := pgxpool.Connect(context.Background(), os.Getenv("DATABASE_URL"))
|
|
if err != nil {
|
|
log.Fatal("Unable to connect to database:", err)
|
|
}
|
|
return pool
|
|
}
|