initialize config plugins

This commit is contained in:
Jinzhu 2021-02-03 16:27:49 +08:00
parent 8f37cb0195
commit 3d3208ed60
2 changed files with 9 additions and 1 deletions

View File

@ -106,6 +106,14 @@ func Open(dialector Dialector, config *Config) (db *DB, err error) {
if config.Plugins == nil {
config.Plugins = map[string]Plugin{}
} else {
for _, p := range config.Plugins {
defer func(plugin Plugin) {
if errr := plugin.Initialize(db); errr != nil {
err = errr
}
}(p)
}
}
if config.cacheStore == nil {

View File

@ -8,7 +8,7 @@ require (
github.com/lib/pq v1.6.0
github.com/stretchr/testify v1.5.1
gorm.io/driver/mysql v1.0.4
gorm.io/driver/postgres v1.0.7
gorm.io/driver/postgres v1.0.8
gorm.io/driver/sqlite v1.1.4
gorm.io/driver/sqlserver v1.0.6
gorm.io/gorm v1.20.12