Files
pangolin/server/README.md
T
wangjia 1629385c70 feat(server): Go 模块骨架 + 工具链 [tsk_L2k2VrEujof8]
新建 server/ Go 模块:
- go.mod: module github.com/wangjia/pangolin/server, Go 1.22
  依赖: go-chi/chi/v5, google/uuid
- tools.go: //go:build tools 锁定 oapi-codegen / golang-migrate 版本
- cmd/server/main.go: chi router + GET /healthz → {"status":"ok"},监听 :8080
- cmd/migrate/main.go: 占位入口(实逻辑归 1e)
- internal/{config,store,apierr,idgen,auth,codes,devices,nodes,usage,admin}/doc.go
  各包职责说明
- Makefile: build/test/vet/lint/generate/migrate-up/migrate-down
- .golangci.yml: govet/errcheck/staticcheck/revive/gofmt 基线
- README.md: 定位 + 目录树 + make 入口说明
- setup.sh: 首次 go mod tidy 引导脚本(go.sum 需运行后生成)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 01:28:37 +08:00

48 lines
1.8 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.
# Pangolin Server
Go 后端控制面,负责账户、套餐、激活码、设备与节点目录管理。架构详见 `../design/server/ARCHITECTURE.md`
## 目录结构
```
server/
├── cmd/
│ ├── server/ # HTTP 服务入口(chi router/healthz/v1 挂载归 1d
│ └── migrate/ # 数据库迁移 CLI 入口(实现归 1e)
├── internal/
│ ├── config/ # 配置加载(env + 文件,归 1e)
│ ├── store/ # 数据库访问层 Postgres(归 1e
│ ├── apierr/ # 统一错误体 {code, message_zh, message_en}(归 1f
│ ├── idgen/ # UUID + Crockford Base32 激活码(归 1f
│ ├── auth/ # 验证码、argon2id、JWT RS256(归 1c/1d
│ ├── codes/ # 激活码批次、兑换、审计(归 1d)
│ ├── devices/ # 设备管理(归 1d)
│ ├── nodes/ # 节点目录、connect/disconnect(归 1d
│ ├── usage/ # 用量统计(归 1d)
│ └── admin/ # 内部管理端(归 1d)
├── Makefile
├── go.mod
├── go.sum
├── tools.go # //go:build tools — 锁定 oapi-codegen / migrate 版本
└── .golangci.yml
```
## 常用命令
```bash
make build # go build ./...
make test # go test ./...
make vet # go vet ./...
make lint # golangci-lint run ./...
make generate # oapi-codegen 代码生成(1d 填充)
make migrate-up # 执行迁移(1e 填充)
make migrate-down # 回滚迁移(1e 填充)
# 快速启动(默认监听 :8080
go run ./cmd/server
# 指定地址
go run ./cmd/server -addr :9090
# 或通过环境变量
ADDR=:9090 go run ./cmd/server
```