Conditions | 3 |
Total Lines | 13 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | package repository |
||
24 | func NewPostgresDB(cfg Config) (*sqlx.DB, error) { |
||
25 | db, err := sqlx.Open("postgres", fmt.Sprintf("host=%s port=%s user=%s dbname=%s password=%s sslmode=%s", |
||
26 | cfg.Host, cfg.Port, cfg.Username, cfg.DBName, cfg.Password, cfg.SSLMode)) |
||
27 | if err != nil { |
||
28 | return nil, err |
||
29 | } |
||
30 | |||
31 | err = db.Ping() |
||
32 | if err != nil { |
||
33 | return nil, err |
||
34 | } |
||
35 | |||
36 | return db, nil |
||
37 | } |
||
38 |