There is an argument to be made that this allows code using `database/sql`
to take the arguments to `Open` directly from an environment
variable/config file and pass them on, to support multiple DBMS. But
really, it would have probably been a better design to directly take the
Driver, yes. However, this was a decision made a long time ago and we can't
really change it now.

Note that there is `sql.OpenDB`, which is pretty much doing what you expect.

On Sat, Jan 15, 2022 at 11:20 PM sina safari <sina.de...@gmail.com> wrote:

> Hi, I have a question about the "database/sql" package.
> Why doesn't the "Open" function take the "driver.Driver" interface instead
> of the driver name?
> like this:
> func Open(driveri driver.Driver, dataSourceName string
> <https://pkg.go.dev/builtin#string>) (*DB
> <https://pkg.go.dev/database/sql#DB>, error
> <https://pkg.go.dev/builtin#error>)
>
> what's the reason?
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/9fad2844-253e-436c-9495-2f44394cc1b0n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/9fad2844-253e-436c-9495-2f44394cc1b0n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfFyVHSVWQxvJ8Ovzc-ZQcAMxJiCh1N-7Zv_RpibofV0XQ%40mail.gmail.com.

Reply via email to