[fix] 多次调用 Open() 错误
This commit is contained in:
parent
9ec1f7b888
commit
cd33e09d69
20
db.go
20
db.go
@ -17,22 +17,20 @@ func (d *DB) SetLogger(f func(log Log)) *DB {
|
||||
}
|
||||
|
||||
func Open(config map[string]DBConfig) *DB {
|
||||
var configP = make(map[string]*DBConfig)
|
||||
if Engine == nil {
|
||||
Engine = &DB{
|
||||
DatabaseManager: DatabaseManager{
|
||||
Configs: make(map[string]*DBConfig),
|
||||
Connections: make(map[string]*Connection),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
for name := range config {
|
||||
c := config[name]
|
||||
configP[name] = &c
|
||||
Engine.Configs[name] = &c
|
||||
}
|
||||
|
||||
db := DB{
|
||||
DatabaseManager: DatabaseManager{
|
||||
Configs: configP,
|
||||
Connections: make(map[string]*Connection),
|
||||
},
|
||||
}
|
||||
|
||||
Engine = &db
|
||||
|
||||
return Engine
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user