URL generates a database connection url from the configuration fields.
()
| 95 | |
| 96 | // URL generates a database connection url from the configuration fields. |
| 97 | func (c *Database) URL() string { |
| 98 | return fmt.Sprintf( |
| 99 | "postgresql://%s:%s@%s:%d/%s?sslmode=%s", |
| 100 | c.Username, |
| 101 | c.Password, |
| 102 | c.Host, |
| 103 | c.Port, |
| 104 | c.DBName, |
| 105 | c.SSLMode, |
| 106 | ) |
| 107 | } |
| 108 | |
| 109 | // Validate checks a Database configuration to ensure it's values are |
| 110 | // valid for connecting to a database. |