Check if provided connection URL has invalid format

This commit is contained in:
Dan Sosedoff 2014-11-11 18:18:35 -06:00
parent dd1127ff77
commit 12bdc36c92

View File

@ -42,6 +42,11 @@ func getConnectionString() string {
if options.Url != "" {
url := options.Url
if strings.Contains(url, "postgresql://") {
fmt.Println("Invalid URL format. It should match: postgres://user:password@host:port/db?sslmode=mode")
os.Exit(1)
}
if options.Ssl != "" && !strings.Contains(url, "sslmode") {
url += fmt.Sprintf("?sslmode=%s", options.Ssl)
}