refactoring everything teehee (i'm so glad this isn't a team project)
Signed-off-by: ari melody <ari@arimelody.me>
This commit is contained in:
parent
c684f0c7ae
commit
10f5f51e76
17 changed files with 970 additions and 547 deletions
24
db/db.go
Normal file
24
db/db.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
func InitDatabase() *sqlx.DB {
|
||||
db, err := sqlx.Connect("postgres", "user=arimelody dbname=arimelody password=fuckingpassword sslmode=disable")
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "unable to create database connection pool: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
db.SetConnMaxLifetime(time.Minute * 3)
|
||||
db.SetMaxOpenConns(10)
|
||||
db.SetMaxIdleConns(10)
|
||||
|
||||
return db
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue