refactor: reorganize modules and add Linux build tooling

This commit is contained in:
2026-08-09 12:41:08 +08:00
parent 86024fa81d
commit 5cc5fd92ed
1461 changed files with 4054 additions and 4724 deletions

View File

@@ -6,21 +6,21 @@ BSM 后端服务的 Go workspace包含基础能力、电商、财务、社交
| 目录 | 服务 |
| --- | --- |
| `apps/base` | ads、cloud、cms、feedback、fts、initial、logs、mgt、passport、sender |
| `apps/ec` | address、delivery、mall、market、order |
| `apps/finance` | wallet |
| `apps/social` | feed、group、relation |
| `module/base` | ads、cloud、cms、feedback、fts、initial、logs、mgt、passport、sender |
| `module/ec` | address、delivery、mall、market、order |
| `module/finance` | wallet |
| `module/social` | feed、group、relation |
| `cmd` | 聚合上述服务的单体启动器 |
| `go.work` | 20 个 Go 模块的 workspace 定义 |
各服务的接口、配置和部署细节见对应 `apps/**/README.md`
各服务的接口、配置和部署细节见对应 `module/**/README.md`
## 环境要求
- Go 1.26.5
- Git
- 按所运行服务准备 PostgreSQL、Redis、etcd、MQ 或对象存储等外部依赖
- 重新生成 protobuf 时,按服务目录中的 `buf.yaml``buf.gen.yaml` 和脚本安装相应生成器
- 重新生成 protobuf 时,按服务目录中的生成脚本或团队约定的 `protoc` 命令安装相应生成器
确认工具链:
@@ -29,6 +29,22 @@ go version
go work sync
```
更新所有 workspace 模块的依赖:
```bash
bash scripts/update-all.sh
```
脚本会为每个模块执行 `go get -u ./...``go mod tidy`,最后运行 `go work sync`;它不会自动提交或推送 Git 变更。
编译全部 19 个独立服务:
```bash
bash scripts/build-all-linux.sh
```
脚本固定交叉编译 Linux x86-64`GOOS=linux``GOARCH=amd64``CGO_ENABLED=0`),产物写入 `builds/<领域>-<模块>``builds/` 已加入 `.gitignore`,聚合入口 `cmd` 不包含在批量构建中。
## 配置
每个服务的 `etc/` 目录包含 `*_dev.yaml``*_test.yaml``*_prod.yaml` 示例。提交到仓库的配置只能包含占位值;请在本地副本或部署系统的密钥管理中注入真实凭据,不要提交数据库密码、访问密钥、令牌或私钥。
@@ -40,7 +56,7 @@ go work sync
运行单个服务时,进入其模块目录。例如:
```bash
cd apps/base/passport
cd module/base/passport
go run ./cmd/main
```
@@ -104,7 +120,7 @@ go test ./...
## 开发约定
- Go 版本声明、Docker 构建镜像和 CI 构建镜像统一为 `1.26.5`
- 新模块必须加入 `go.work`,并确保本地 `replace` 使用当前 `apps/...` 目录结构。
- 新模块必须加入 `go.work`,并确保本地 `replace` 使用当前 `module/...` 目录结构。
- protobuf 描述符必须包含服务命名空间,避免多个服务聚合到同一进程时发生全局文件名冲突。
- 外部依赖测试使用 `//go:build integration`,不得让默认测试依赖网络或已启动服务。
- 配置和测试数据中不得包含真实凭据或个人信息。