I've mailed a CL for this proposal. After trying to implement it I'm actually very happy with the result and would recommend we merge it into go1.10 as it will complement the driver.Connector nicely (also added in go1.10.
Rather then just creating an OpenContext(ctx context.Context, name string) optional method, I create an interface that returns a driver.Connector. Not only do we get the context as requested in this issue, we also gain the DSN is only parsed once and it is parsed before the database pool is created (not on first ping). This will be more efficient, propagate context regardless of how the DB was opened, and return DSN parse errors sooner.
I see this as a strong win and buys the extra interface it adds.
@kardianos awesome! I think OpenConnector is more friendly with driver developer for compatibility.
In production, sometimes we found that max latency of query up to one minute with a seconds-timeout context.
It is easy to found out that the routine hangs in driver.Open function and returns after dial or read/write timeout (read/write happens in connection initialization).