change connStr format
This commit is contained in:
parent
0e0d2b94b6
commit
386a24affb
@ -15,7 +15,12 @@ var x *sqlx.DB
|
||||
func NewDB() (*sqlx.DB, error) {
|
||||
var err error
|
||||
conf := config.GetConf()
|
||||
connStr := fmt.Sprintf("user=%s password=%s host=%s sslmode=disable dbname=%s port=%d", conf.Database.User, conf.Database.Pass, conf.Database.Host, conf.Database.DB, conf.Database.Port)
|
||||
userPassStr := conf.Database.User
|
||||
if len(conf.Database.Pass) > 0 {
|
||||
userPassStr += ":" + conf.Database.Pass
|
||||
}
|
||||
connStr := fmt.Sprintf("postgres://%s@%s/%s?sslmode=disable", userPassStr, conf.Database.Host, conf.Database.DB)
|
||||
// connStr := fmt.Sprintf("user=%s password=%s host=%s sslmode=disable dbname=%s port=%d", conf.Database.User, conf.Database.Pass, conf.Database.Host, conf.Database.DB, conf.Database.Port)
|
||||
x, err = sqlx.Connect("postgres", connStr)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
Loading…
Reference in New Issue
Block a user