diff --git a/dsn.go b/dsn.go index 1d9b4ab0a..78fd63159 100644 --- a/dsn.go +++ b/dsn.go @@ -150,7 +150,7 @@ func (cfg *Config) normalize() error { // FormatDSN formats the given Config into a DSN string which can be passed to // the driver. -func (cfg *Config) FormatDSN() string { +func (cfg *Config) FormatDSN() (dsn string, err error) { var buf bytes.Buffer // [username[:password]@] @@ -368,7 +368,7 @@ func (cfg *Config) FormatDSN() string { } } - return buf.String() + return buf.String(), nil } // ParseDSN parses the DSN string to a Config diff --git a/dsn_test.go b/dsn_test.go index 50dc2932c..de995bf37 100644 --- a/dsn_test.go +++ b/dsn_test.go @@ -120,7 +120,7 @@ func TestDSNReformat(t *testing.T) { cfg1.tls = nil // pointer not static res1 := fmt.Sprintf("%+v", cfg1) - dsn2 := cfg1.FormatDSN() + dsn2, _ := cfg1.FormatDSN() cfg2, err := ParseDSN(dsn2) if err != nil { t.Error(err.Error()) @@ -312,7 +312,7 @@ func TestParamsAreSorted(t *testing.T) { "quux": "loo", "foobar": "baz", } - actual := cfg.FormatDSN() + actual, _ := cfg.FormatDSN() if actual != expected { t.Errorf("generic Config.Params were not sorted: want %#v, got %#v", expected, actual) }