mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-11-11 07:41:10 +00:00
project structure
This commit is contained in:
20
pkg/utl/pg/pg.go
Normal file
20
pkg/utl/pg/pg.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package pg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"wallet-api/pkg/utl/common"
|
||||
|
||||
"github.com/go-pg/pg/v10"
|
||||
)
|
||||
|
||||
func CreateConnection() func() *pg.DB {
|
||||
opt, err := pg.ParseURL(os.Getenv("DATABASE_URL"))
|
||||
common.CheckError(err)
|
||||
|
||||
db := pg.Connect(opt)
|
||||
fmt.Println("Successfully connected!")
|
||||
return func() *pg.DB {
|
||||
return db
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user