v1.0.0
Code reorganization + added meta tags and favicon
This commit is contained in:
1 parent
45b220c69f
commit
c6f365ab28
22 files changed
+566
-415
No files matched your search
@@ -0,0 +1,30 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
//go:embed dev/*.sql
|
||||
var DevMigrations embed.FS
|
||||
|
||||
//go:embed prod/*.sql
|
||||
var ProdMigrations embed.FS
|
||||
|
||||
func ConnectToDbNamed(host string, port string, user string, password string, dbname string) (*sqlx.DB, error) {
|
||||
psqlInfo := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=disable",
|
||||
host, port, user, password, dbname)
|
||||
|
||||
db, err := sqlx.Open("postgres", psqlInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = db.Ping()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return db, nil
|
||||
}
|
||||
Reference in new issue
Block a user