From 12bdc36c92b64cc5cbd3fc9d5a9cfc8deca3bbfb Mon Sep 17 00:00:00 2001 From: Dan Sosedoff Date: Tue, 11 Nov 2014 18:18:35 -0600 Subject: [PATCH] Check if provided connection URL has invalid format --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index 33901fa..e809abe 100644 --- a/main.go +++ b/main.go @@ -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) }