good morning!!!!

Skip to content
Snippets Groups Projects
Commit 69fd721e authored by Carlos Nieto's avatar Carlos Nieto
Browse files

Merge pull request #22 from maxhawkins/connstring

PostgreSQL: don't set 'user' or 'pass' in conn string when not provided
parents f833ffcb 5431cb64
No related branches found
No related tags found
No related merge requests found
......@@ -223,15 +223,20 @@ func (self *Source) Open() error {
}
var conn string
if user := self.config.User; user != "" {
conn += fmt.Sprintf(`user=%s `, user)
}
if pass := self.config.Password; pass != "" {
conn += fmt.Sprintf(`password=%s `, pass)
}
if self.config.Host != "" {
conn = fmt.Sprintf(`user=%s password=%s host=%s port=%d dbname=%s sslmode=%s`, self.config.User, self.config.Password, self.config.Host, self.config.Port, self.config.Database, SSLMode)
} else if self.config.Socket != `` {
conn = fmt.Sprintf(`user=%s password=%s host=%s dbname=%s sslmode=%s`, self.config.User, self.config.Password, self.config.Socket, self.config.Database, SSLMode)
conn += fmt.Sprintf(`host=%s port=%d `, self.config.Host, self.config.Port)
} else {
conn += fmt.Sprintf(`host=%s `, self.config.Socket)
}
conn += fmt.Sprintf(`dbname=%s sslmode=%s`, self.config.Database, SSLMode)
self.session, err = sql.Open(`postgres`, conn)
if err != nil {
return err
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment