|
|
1 月之前 | |
|---|---|---|
| .opencode/skills | 1 月之前 | |
| internal | 1 月之前 | |
| sql | 1 月之前 | |
| sync-sql | 1 月之前 | |
| tables | 1 月之前 | |
| web | 1 月之前 | |
| .gitignore | 1 月之前 | |
| README-frontend.md | 1 月之前 | |
| README.md | 1 月之前 | |
| gct.sh | 1 月之前 | |
| go.mod | 1 月之前 | |
| go.sum | 1 月之前 | |
| main.go | 1 月之前 | |
| run.sh | 1 月之前 |
简单的Go微服务,用于管理AI代码生成会话、项目和提示词。
go build -o svc-code .
./svc-code
服务将在 http://localhost:8787 启动。
打开浏览器访问 http://localhost:8787
GET /session - 获取会话列表POST /session - 创建新会话GET /session/:id - 获取会话详情PUT /session/:id - 更新会话DELETE /session/:id - 删除会话GET /project - 获取项目列表POST /project - 创建新项目GET /project/current - 获取当前项目GET /global/health - 健康检查GET /global/event - 事件流(SSE)表定义在 tables/ 目录:
code_sessions - 会话表code_projects - 项目表code_prompts - 提示词表服务启动时自动创建表(如果使用数据库)。
使用go-base配置框架,支持YAML配置文件或环境变量。
app:
name: svc-code
version: "1"
service:
port: 8787
database:
host: localhost
port: 3306
name: code_service
username: root
password: ""
mongodb:
uri: mongodb://localhost:27017
database: code_service
handlers/ 目录创建新的处理函数main.go 的 registerDefaultRouter 中注册路由tables/ 目录创建新表定义web/ 目录添加HTML/JS/CSS文件/ 路径访问# 运行开发服务器
go run .
# 代码检查
go vet .
go fmt .
# 测试
go test ./...