From cd33e09d6974177fff01b99376675ec8bb16ca11 Mon Sep 17 00:00:00 2001 From: what Date: Wed, 21 Jun 2023 09:56:28 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E5=A4=9A=E6=AC=A1=E8=B0=83=E7=94=A8=20?= =?UTF-8?q?Open()=20=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/db.go b/db.go index c31962f..ff1d1f6 100644 --- a/db.go +++ b/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 }