# smart-core **Repository Path**: hubert_rust/smart-core ## Basic Information - **Project Name**: smart-core - **Description**: 和smart-core, smarat-common, smart-cluster, smart-front为一个整体 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-17 - **Last Updated**: 2026-06-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # smart-core 多服务共用的 **Go 基建库**(无业务域):配置子结构、MySQL/PostgreSQL/SQLite/GORM 连接池、Redis、Zap 日志、Gin HTTP 辅助。 - **smart-cluster**:应用配置在 `smart-cluster/internal/config`,其中 `server` / `database` / `redis` / `log` 字段类型来自本模块 `smart-core/config`;DB/Redis/Logger 初始化使用 `smart-core/database`、`smart-core/redis`、`smart-core/logger`;HTTP 响应封装使用 `smart-core/httpgin`。 - **smart-common**:按需 `require smart-core`(例如 `gormstore.NewStoreFromMySQL` 使用 `smart-core/database.OpenGORM`)。 - **smart-ai**:使用 PostgreSQL 15,通过 `database.driver: postgres` 接入。 依赖方向:`smart-core` 不依赖 `smart-common` / `smart-cluster`。 ## 数据库(database) `InitWithName` / `GORMByName` / `OpenGORM` 支持 **mysql**、**postgres**(`postgresql` 别名)与 **sqlite**。 ### MySQL 示例 ```yaml database: driver: mysql host: 127.0.0.1 port: 3306 user: root password: secret database: smart_cluster charset: utf8mb4 ``` ### PostgreSQL 示例 ```yaml database: driver: postgres host: 123.60.219.212 port: 5432 user: postgres password: secret database: smart_ai ssl_mode: disable # 缺省 disable;生产可改为 require ``` 底层驱动:`mysql` 使用 `go-sql-driver/mysql`;`postgres` 使用 `jackc/pgx/v5` + `gorm.io/driver/postgres`;`sqlite` 使用 `github.com/glebarez/sqlite`(纯 Go,无 CGO)。 ### SQLite 示例 ```yaml database: driver: sqlite path: data/smart-ai.db # 也可用 database 字段指定文件路径 print_sql: false ``` 内存库(单测/本地演示):`path: "file::memory:?cache=shared"` 本地与 `smart-cluster`、`smart-common` 同级目录时,在消费者 `go.mod` 中: ```go require smart-core v0.0.0 replace smart-core => ../smart-core ```