mysql icon indicating copy to clipboard operation
mysql copied to clipboard

Move ParseDSN into sub package

Open byrnedo opened this issue 9 years ago • 1 comments

Issue description

Would be good to have ParseDSN/Config struct in another package than mysql since the init function registers the mysql driver, so you can't access it without it registering.

My use case is I wanted to have a simple port check for mysql, obtaining the Addr from ParseDSN. Problem is that since it registers the driver, if I subsequently import my utility package it's not easy to see that it's already registered that driver and the app will panic.

Error log

sql: Register called twice for driver mysql

byrnedo avatar May 10 '16 09:05 byrnedo

Sorry for taking so long to reply.

We should probably do this and it came up before, just Config.tls has to be dealt with somehow. But I can't provide a timeline and it's pretty low on my list of priorities.

Short term, you are best served by copying the parsing code.

Unrelated: how do you get in a situation where init is called twice for a package? Is this in a tool supporting multiple drivers registering under the same name?

arnehormann avatar Jun 09 '16 08:06 arnehormann