This commit is contained in:
oneao committed 2026-04-07 17:19:52 +08:00
1 parent c6671c8a8c
commit f0cb963d23
76 files changed
+6467 -498

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
package bootstrap
import (
"allapp-go/internal/bootstrap/boots"
"allapp-go/internal/config"
"allapp-go/pkg/db"
"allapp-go/pkg/logger"
"github.com/jackc/pgx/v5/pgxpool"
)
type App struct {
Config *config.Config
PgSql *pgxpool.Pool
}
// ======================
// 初始化
// ======================
func NewApp() (*App, error) {
cfg, err := config.Load()
if err != nil {
return nil, err
}
// 日志
boots.InitLogger(cfg)
// 数据库
pgsql, err := boots.InitPgsql(cfg)
if err != nil {
return nil, err
}
db.Init(pgsql)
// 其他组件
boots.InitUniqueId(cfg)
boots.InitJwt(cfg)
return &App{
Config: cfg,
PgSql: pgsql,
}, nil
}
// ======================
// 释放资源
// ======================
func (a *App) Close() {
if a.PgSql != nil {
a.PgSql.Close()
}
logger.Sync()
}