24 lines
536 B
Go
24 lines
536 B
Go
package shared
|
|
|
|
import (
|
|
"github.com/spf13/viper"
|
|
"net/url"
|
|
)
|
|
|
|
func GetPostgresURI() string {
|
|
postgresURI := url.URL{
|
|
Scheme: "postgresql",
|
|
User: url.UserPassword(viper.GetString("database.user"), viper.GetString("database.password")),
|
|
Host: viper.GetString("database.host"),
|
|
Path: viper.GetString("database.database"),
|
|
}
|
|
|
|
values := postgresURI.Query()
|
|
|
|
values.Add("sslmode", "disable")
|
|
values.Add("timezone", viper.GetString("database.tz"))
|
|
|
|
postgresURI.RawQuery = values.Encode()
|
|
|
|
return postgresURI.String()
|
|
}
|