123456789101112131415161718192021222324252627282930 |
- package gs
- import (
- "gogs.tyduyong.com/duyong/dy-admin/internal/iam/config"
- "gorm.io/gorm"
- "sync"
- )
- // GlobalSource 服务依赖的外部通用资源
- type GlobalSource struct {
- PGSqlDB *gorm.DB
- MYSqlDB *gorm.DB
- }
- var (
- GS *GlobalSource
- once = sync.Once{}
- )
- func InitGS(config *config.Config) {
- // 初始化
- once.Do(func() {
- gs := &GlobalSource{}
- // pgsql
- pgDB := InitPGSqlDB(config.PGSQLOptions)
- gs.PGSqlDB = pgDB
- GS = gs
- })
- }
|