为什么在下面的示例中编译器说不sql.Tx
实现driver.Tx
,看到sql.Tx
确实实现了接口:
import (
"database/sql"
"database/sql/driver"
)
func main() {
var myDB store = db{}
}
type store interface {
Store(tx driver.Tx)
}
type db struct {}
func (db) Store(tx *sql.Tx) {}
type Tx interface {
Commit() error
Rollback() error
}
./prog.go:9:6: cannot use db{} (type db) as type store in assignment:
db does not implement store (wrong type for Store method)
have Store(*sql.Tx)
want Store(driver.Tx)