+3
−0
+1
−1
connector.go
0 → 100644
+108
−0
connector_test.go
0 → 100644
+285
−0
+6
−0
Loading
database/sql offers no way to reach a registered driver: sql.Drivers returns
names only and there is no sql.Driver(name). The single route from the
"sqlite" name back to the driver value is (*sql.DB).Driver(), which is why
callers who need it resort to
db, _ := sql.Open("sqlite", "")
drv := db.Driver()
db.Close()
That opens nothing - it works only because sql.Open does not connect and
*Driver does not implement driver.DriverContext. Both are properties this
package could change without noticing it had broken anyone.
Callers want the driver in order to interpose on the physical connections
database/sql opens: tracing, metrics, connection-scoped setup. Handing out
the driver alone would not be enough, because the only way to get a wrapper
into a *sql.DB through sql.Open is sql.Register, which is process-global,
panics on a name it has already seen and cannot be undone - so a library has
to invent a unique name per configuration. TestConnectio...