project structure

This commit is contained in:
Fran Jurmanović
2021-05-02 20:35:00 +02:00
parent 9a272d47c4
commit 3a5138eb83
10 changed files with 292 additions and 0 deletions

20
pkg/utl/pg/pg.go Normal file
View 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
}
}