go-mysql-org / go-mysql

a powerful mysql toolset with Go
MIT License
4.58k stars 976 forks source link

Support DSN without 'user:password@' #888

Closed dvilaverde closed 3 months ago

dvilaverde commented 3 months ago

I noticed that a DSN like this:

db.example.com:3307/db?ssl=true

would incorrectly have the property db in the connInfo object set to ssl=true when it should have been set to db.

According to the README the DSN format allows for an optional user:password@.

[user[:password]@]addr[/db[?param=X]]

Adding unit tests for the ParseDSN function to cover those cases.