完善资源关闭逻辑,添加数据库和Redis连接的退出处理

This commit is contained in:
2025-04-01 11:26:37 +08:00
parent 6d89470a89
commit 87eecdb8cb
7 changed files with 74 additions and 50 deletions

View File

@@ -47,6 +47,17 @@ func Init() {
DB = db
}
func Exit() error {
if DB != nil {
conn, err := DB.DB()
if err != nil {
return err
}
return conn.Close()
}
return nil
}
type WithAlias interface {
Alias() string
}