docs: 优化 README 格式与 YAML 缩进

This commit is contained in:
unclesam committed 2026-07-08 07:21:29 +08:00
1 parent 85265abb48
commit c5977ce354
1 file changed
+42 -21
+42 -21
View File
@@ -9,7 +9,9 @@
A production-ready Go backend project scaffolding based on **Ent ORM + Gin + Cobra**, out of the box. A production-ready Go backend project scaffolding based on **Ent ORM + Gin + Cobra**, out of the box.
### Features ### Features
* **ORM**: [Ent](https://entgo.io/) - An entity framework for Go. Strongly-typed, code-generated schema definitions, automatic migration, and clean graph queries.
* **ORM**: [Ent](https://entgo.io/) - An entity framework for Go. Strongly-typed, code-generated schema definitions,
automatic migration, and clean graph queries.
* **Router**: [Gin](https://github.com/gin-gonic/gin) - High-performance HTTP routing. * **Router**: [Gin](https://github.com/gin-gonic/gin) - High-performance HTTP routing.
* **CLI Command**: [Cobra](https://github.com/spf13/cobra) - Rich CLI subcommands (`server`, `migrate`, `user`, `gen`). * **CLI Command**: [Cobra](https://github.com/spf13/cobra) - Rich CLI subcommands (`server`, `migrate`, `user`, `gen`).
* **Configurations**: [Viper](https://github.com/spf13/viper) - YAML configuration with hot-reloading support. * **Configurations**: [Viper](https://github.com/spf13/viper) - YAML configuration with hot-reloading support.
@@ -53,28 +55,33 @@ EnGin/
### Getting Started ### Getting Started
#### Prerequisites #### Prerequisites
* Go >= 1.25 * Go >= 1.25
* MySQL or PostgreSQL * MySQL or PostgreSQL
* Redis (Optional, needed for token blacklist verification) * Redis (Optional, needed for token blacklist verification)
#### 1. Setup Configuration #### 1. Setup Configuration
Edit `configs/config.yaml` to fill in database details: Edit `configs/config.yaml` to fill in database details:
```yaml ```yaml
database: database:
driver: "postgres" # postgres or mysql driver: "postgres" # postgres or mysql
host: "127.0.0.1" host: "127.0.0.1"
port: 5432 port: 5432
user: "postgres" user: "postgres"
password: "your_password" password: "your_password"
dbname: "engin_db" dbname: "engin_db"
``` ```
#### 2. Install Dependencies #### 2. Install Dependencies
```bash ```bash
go mod tidy go mod tidy
``` ```
#### 3. Run Commands #### 3. Run Commands
```bash ```bash
# Run migrations (creates tables and intermediate join tables) # Run migrations (creates tables and intermediate join tables)
go run cmd/server/*.go migrate go run cmd/server/*.go migrate
@@ -93,9 +100,11 @@ go run cmd/server/*.go server
基于 **Ent ORM + Gin + Cobra** 的开箱即用型 Go 后端项目脚手架。 基于 **Ent ORM + Gin + Cobra** 的开箱即用型 Go 后端项目脚手架。
### 项目特性 ### 项目特性
* **ORM**:[Ent](https://entgo.io/) - 强类型、代码生成式的图结构实体框架,支持智能迁移与极简联表。 * **ORM**:[Ent](https://entgo.io/) - 强类型、代码生成式的图结构实体框架,支持智能迁移与极简联表。
* **Web 框架**:[Gin](https://github.com/gin-gonic/gin) - 高性能 HTTP 路由分发。 * **Web 框架**:[Gin](https://github.com/gin-gonic/gin) - 高性能 HTTP 路由分发。
* **命令行**:[Cobra](https://github.com/spf13/cobra) - 规范 of CLI 命令工具集(`server` 运行、`migrate` 迁移、`user` 管理、`gen` 生成)。 * **命令行**:[Cobra](https://github.com/spf13/cobra) - 规范 of CLI 命令工具集(`server` 运行、`migrate` 迁移、`user` 管理、
`gen` 生成)。
* **配置管理**:[Viper](https://github.com/spf13/viper) - 支持 YAML 映射与动态热加载。 * **配置管理**:[Viper](https://github.com/spf13/viper) - 支持 YAML 映射与动态热加载。
* **缓存与注销**:集成 Redis (go-redis/v9),支持基于黑名单的 Token 安全注销。 * **缓存与注销**:集成 Redis (go-redis/v9),支持基于黑名单的 Token 安全注销。
* **安全鉴权**:支持双 Token (Access Token & Refresh Token) 安全刷新机制。 * **安全鉴权**:支持双 Token (Access Token & Refresh Token) 安全刷新机制。
@@ -136,28 +145,33 @@ EnGin/
### 快速开始 ### 快速开始
#### 环境要求 #### 环境要求
* Go >= 1.25 * Go >= 1.25
* MySQL 或 PostgreSQL * MySQL 或 PostgreSQL
* Redis (可选,用于黑名单过滤) * Redis (可选,用于黑名单过滤)
#### 1. 配置参数 #### 1. 配置参数
编辑 `configs/config.yaml` 填写对应数据库信息: 编辑 `configs/config.yaml` 填写对应数据库信息:
```yaml ```yaml
database: database:
driver: "postgres" # mysql 或 postgres driver: "postgres" # mysql 或 postgres
host: "127.0.0.1" host: "127.0.0.1"
port: 5432 port: 5432
user: "postgres" user: "postgres"
password: "你的密码" password: "你的密码"
dbname: "engin_db" dbname: "engin_db"
``` ```
#### 2. 下载依赖 #### 2. 下载依赖
```bash ```bash
go mod tidy go mod tidy
``` ```
#### 3. 运行指南 #### 3. 运行指南
```bash ```bash
# 自动生成数据库表(包括 M2M 中间表) # 自动生成数据库表(包括 M2M 中间表)
go run cmd/server/*.go migrate go run cmd/server/*.go migrate
@@ -176,9 +190,11 @@ go run cmd/server/*.go server
**Ent ORM + Gin + Cobra** に基づく、すぐに使えるプロダクション対応の Go バックエンドプロジェクトスケルトン(脚手架)です。 **Ent ORM + Gin + Cobra** に基づく、すぐに使えるプロダクション対応の Go バックエンドプロジェクトスケルトン(脚手架)です。
### 主な機能と特徴 ### 主な機能と特徴
* **ORM**: [Ent](https://entgo.io/) - 強力な静的型付けコード生成型のグラフ構造 ORM。簡単なリレーション構築とマイグレーションをサポート。 * **ORM**: [Ent](https://entgo.io/) - 強力な静的型付けコード生成型のグラフ構造 ORM。簡単なリレーション構築とマイグレーションをサポート。
* **Web フレームワーク**: [Gin](https://github.com/gin-gonic/gin) - 高速な HTTP ルーティング。 * **Web フレームワーク**: [Gin](https://github.com/gin-gonic/gin) - 高速な HTTP ルーティング。
* **CLI コマンド**: [Cobra](https://github.com/spf13/cobra) - 構造化されたサブコマンド体系(`server`, `migrate`, `user`, `gen`)。 * **CLI コマンド**: [Cobra](https://github.com/spf13/cobra) - 構造化されたサブコマンド体系(`server`, `migrate`, `user`,
`gen`)。
* **設定管理**: [Viper](https://github.com/spf13/viper) - YAML 設定ファイルのマッピングとホットリロードのサポート。 * **設定管理**: [Viper](https://github.com/spf13/viper) - YAML 設定ファイルのマッピングとホットリロードのサポート。
* **キャッシュ / ログアウト**: Redis (go-redis/v9) によるログアウト Token ブラックリスト管理。 * **キャッシュ / ログアウト**: Redis (go-redis/v9) によるログアウト Token ブラックリスト管理。
* **認証**: デュアルトークン (Access Token & Refresh Token) による安全な認証スキーム。 * **認証**: デュアルトークン (Access Token & Refresh Token) による安全な認証スキーム。
@@ -219,28 +235,33 @@ EnGin/
### クイックスタート ### クイックスタート
#### 動作要件 #### 動作要件
* Go >= 1.25 * Go >= 1.25
* MySQL または PostgreSQL * MySQL または PostgreSQL
* Redis (オプション、ログアウトブラックリスト機能に必要) * Redis (オプション、ログアウトブラックリスト機能に必要)
#### 1. 設定ファイルの編集 #### 1. 設定ファイルの編集
`configs/config.yaml` のデータベース接続情報を設定します: `configs/config.yaml` のデータベース接続情報を設定します:
```yaml ```yaml
database: database:
driver: "postgres" # mysql または postgres driver: "postgres" # mysql または postgres
host: "127.0.0.1" host: "127.0.0.1"
port: 5432 port: 5432
user: "postgres" user: "postgres"
password: "your_password" password: "your_password"
dbname: "engin_db" dbname: "engin_db"
``` ```
#### 2. 依存関係のインストール #### 2. 依存関係のインストール
```bash ```bash
go mod tidy go mod tidy
``` ```
#### 3. コマンドの実行 #### 3. コマンドの実行
```bash ```bash
# マイグレーションを実行し、中間テーブルなどを自動生成 # マイグレーションを実行し、中間テーブルなどを自動生成
go run cmd/server/*.go migrate go run cmd/server/*.go migrate