nap
nap copied to clipboard
Port to gorm
Can I use this with the gorm(https://github.com/jinzhu/gorm).
If yes, can you give any example code(noob here).
Hi, I'm trying to use this on gorm too. And I made a wrapper on it try to act as a driver.
but I got some error.
and here is my code
package driver
import (
"database/sql"
"database/sql/driver"
"github.com/go-sql-driver/mysql"
"github.com/tsenart/nap"
)
type MySQLSplitDriver struct {
mysql.MySQLDriver
}
func (d MySQLSplitDriver) Open(dsn string) (driver.Conn, error) {
return nap.Open("mysql", dsn)
}
func init() {
sql.Register("mysqlsplit", &MySQLSplitDriver{})
}
I think this might be a decent way to use it. Could you make a fix?