go-service-scaffolder
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGo Service Scaffolder
Go 服务脚手架
Create a production-ready Go HTTP service skeleton and keep outputs consistent.
创建生产级Go HTTP服务骨架并保持输出一致性。
Workflow
工作流程
- Ask for required inputs:
- App name (kebab-case)
- Go module path
- GitHub owner/org
- If the user asks for database support, ask which database to scaffold: Postgres, SQLite, or both.
- Derive:
- : uppercase app name without hyphens +
CONFIG_ENV_VAR_CONFIG - : lowercase app name without hyphens
METRICS_PREFIX
-
Generate the full project file tree and file contents using the canonical spec in.
references/go-service-scaffold-spec.md -
Replace placeholders everywhere:
{{APP_NAME}}{{MODULE_PATH}}{{GITHUB_OWNER}}{{CONFIG_ENV_VAR}}{{METRICS_PREFIX}}
Database constraints when database support is requested:
- Never use an ORM.
- For Postgres, use PGX: .
github.com/jackc/pgx/v5 - For SQLite, use .
modernc.org/sqlite
- Run:
- (only if
go mod init <module-path>does not already exist)go.mod go mod tidygo test ./...
- Initialize git only when needed:
- Run only if the target directory is not already a git repository.
git init
- 询问必要输入信息:
- 应用名称(kebab-case格式)
- Go模块路径
- GitHub所有者/组织
- 如果用户要求数据库支持,询问要搭建的数据库类型:Postgres、SQLite,或两者都要。
- 推导生成:
- :大写的应用名称(不含连字符) +
CONFIG_ENV_VAR_CONFIG - :小写的应用名称(不含连字符)
METRICS_PREFIX
-
使用中的标准规范生成完整的项目文件树及文件内容。
references/go-service-scaffold-spec.md -
替换所有占位符:
{{APP_NAME}}{{MODULE_PATH}}{{GITHUB_OWNER}}{{CONFIG_ENV_VAR}}{{METRICS_PREFIX}}
当请求数据库支持时的数据库约束:
- 绝不使用ORM。
- 对于Postgres,使用PGX:。
github.com/jackc/pgx/v5 - 对于SQLite,使用。
modernc.org/sqlite
- 执行以下命令:
- (仅当
go mod init <module-path>不存在时执行)go.mod go mod tidygo test ./...
- 仅在需要时初始化git:
- 仅当目标目录尚未是git仓库时,执行。
git init
Reference
参考文档
Use as the single source of truth for:
references/go-service-scaffold-spec.md- Required directory structure
- Exact file templates
- Post-scaffold steps and architecture notes
Load only the sections needed for the current task instead of reading the entire reference at once.
将作为唯一权威参考,用于:
references/go-service-scaffold-spec.md- 必需的目录结构
- 精确的文件模板
- 脚手架搭建后的步骤及架构说明
仅加载当前任务所需的章节,而非一次性读取整个参考文档。