I thought the Connector was to be able to do away with using inflexible DSNs, and also to avoid having to globally sql.Register drivers?
But current interface methods Connector.Driver(), and Driver.Open(name string) kind of forces an implementation to use DSNs, rather unnecessarily I think.
func main() {
mysqlx.WithDatabase("test"),
mysqlx.WithUserPassword("testuser", "password"),
mysqlx.WithCharset("utf8mb4"),
mysqlx.WithIsolationLevel(sql.LevelReadCommitted),
)
if err != nil {
log.Fatalf("creating connector failed: %s", err)
}
db := sql.OpenDB(connector)
err = db.Ping()
if err != nil {
log.Fatalf("ping failed: %s", err)
}
db.Close()
}