Files
lab/go/projects/lyra/README.md
T
labmem 8b320817ed feat(lyra): 搭建基础骨架与配置响应组件
- 使用 Viper 加载 TOML 配置
- 定义统一响应、业务错误码及响应辅助函数
- 添加分层职责约束并同步架构文档
2026-10-16 23:36:34 +08:00

43 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Lyra
链接、分类、设置等资源的后端服务(规划中)。目标结构与技术选型见
[docs/architecture.md](docs/architecture.md)。
## 当前状态
已搭建目录骨架与程序入口 `main.go`,各内部目录的职责与依赖约束记录在 `AGENTS.md` 中。
`internal/api/response.go` 定义公共响应结构;仅含 `AGENTS.md` 的目录暂不构成 Go 包。
业务逻辑、数据库访问、HTTP API 与迁移文件均未实现;架构文档中标注示例的
文件(links 等)尚未创建。当前运行程序后直接退出——不连接数据库,
也不启动 HTTP 服务。
## 目录职责
| 路径 | 职责 |
|---|---|
| `cmd/lyra/` | 程序入口:启动、依赖组装、退出清理(待实现) |
| `internal/api/` | HTTP 请求/响应 DTO,按资源分文件 |
| `internal/config/` | 配置定义与加载 |
| `internal/postgres/` | PostgreSQL 连接(pgx stdlib) |
| `internal/router/` | 路由注册、项目路径前缀 |
| `internal/handler/` | 参数绑定、DTO 转换、响应输出 |
| `internal/service/` | 业务规则、事务协调 |
| `internal/model/` | 数据结构定义与数据访问(SQL) |
| `internal/httpx/` | 公共响应辅助,按需实现 |
| `migrations/` | Goose SQL 迁移文件(暂无) |
| `docs/` | 架构与计划文档 |
## 运行
Go 命令在本目录(module 根)下执行:
```bash
go run ./cmd/lyra # 当前直接退出,不连接数据库、不启动 HTTP
go test ./... # 当前无测试文件,仅验证各包可编译
```
## 技术栈
已引入 Gin 与 Viper(读取 TOML 配置),go.sum 已生成;
PostgreSQL、Squirrel + sqlx(pgx stdlib 驱动)与 Goose 为目标选型,随后续功能引入。