mirror of https://github.com/go-gorm/gorm.git
Return pointer when Open
This commit is contained in:
parent
84942c60b8
commit
f574429f5e
4
main.go
4
main.go
|
@ -36,7 +36,7 @@ type DB struct {
|
||||||
joinTableHandlers map[string]JoinTableHandler
|
joinTableHandlers map[string]JoinTableHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
func Open(dialect string, args ...interface{}) (DB, error) {
|
func Open(dialect string, args ...interface{}) (*DB, error) {
|
||||||
var db DB
|
var db DB
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ func Open(dialect string, args ...interface{}) (DB, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return db, err
|
return &db, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DB) Close() error {
|
func (s *DB) Close() error {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
DB gorm.DB
|
DB *gorm.DB
|
||||||
t1, t2, t3, t4, t5 time.Time
|
t1, t2, t3, t4, t5 time.Time
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ func init() {
|
||||||
runMigration()
|
runMigration()
|
||||||
}
|
}
|
||||||
|
|
||||||
func OpenTestConnection() (db gorm.DB, err error) {
|
func OpenTestConnection() (db *gorm.DB, err error) {
|
||||||
switch os.Getenv("GORM_DIALECT") {
|
switch os.Getenv("GORM_DIALECT") {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
// CREATE USER 'gorm'@'localhost' IDENTIFIED BY 'gorm';
|
// CREATE USER 'gorm'@'localhost' IDENTIFIED BY 'gorm';
|
||||||
|
|
Loading…
Reference in New Issue