Skip to content

return error in Config.FormatDSN #1046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]@]
Expand Down Expand Up @@ -368,7 +368,7 @@ func (cfg *Config) FormatDSN() string {
}
}

return buf.String()
return buf.String(), nil
}

// ParseDSN parses the DSN string to a Config
Expand Down
4 changes: 2 additions & 2 deletions dsn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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)
}
Expand Down