go-service-scaffolder

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Go Service Scaffolder

Go 服务脚手架

Create a production-ready Go HTTP service skeleton and keep outputs consistent.
创建生产级Go HTTP服务骨架并保持输出一致性。

Workflow

工作流程

  1. 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.
  1. Derive:
  • CONFIG_ENV_VAR
    : uppercase app name without hyphens +
    _CONFIG
  • METRICS_PREFIX
    : lowercase app name without hyphens
  1. Generate the full project file tree and file contents using the canonical spec in
    references/go-service-scaffold-spec.md
    .
  2. 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
    .
  1. Run:
  • go mod init <module-path>
    (only if
    go.mod
    does not already exist)
  • go mod tidy
  • go test ./...
  1. Initialize git only when needed:
  • Run
    git init
    only if the target directory is not already a git repository.
  1. 询问必要输入信息:
  • 应用名称(kebab-case格式)
  • Go模块路径
  • GitHub所有者/组织
  • 如果用户要求数据库支持,询问要搭建的数据库类型:Postgres、SQLite,或两者都要。
  1. 推导生成:
  • CONFIG_ENV_VAR
    :大写的应用名称(不含连字符) +
    _CONFIG
  • METRICS_PREFIX
    :小写的应用名称(不含连字符)
  1. 使用
    references/go-service-scaffold-spec.md
    中的标准规范生成完整的项目文件树及文件内容。
  2. 替换所有占位符:
  • {{APP_NAME}}
  • {{MODULE_PATH}}
  • {{GITHUB_OWNER}}
  • {{CONFIG_ENV_VAR}}
  • {{METRICS_PREFIX}}
当请求数据库支持时的数据库约束:
  • 绝不使用ORM。
  • 对于Postgres,使用PGX:
    github.com/jackc/pgx/v5
  • 对于SQLite,使用
    modernc.org/sqlite
  1. 执行以下命令:
  • go mod init <module-path>
    (仅当
    go.mod
    不存在时执行)
  • go mod tidy
  • go test ./...
  1. 仅在需要时初始化git:
  • 仅当目标目录尚未是git仓库时,执行
    git init

Reference

参考文档

Use
references/go-service-scaffold-spec.md
as the single source of truth for:
  • 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
作为唯一权威参考,用于:
  • 必需的目录结构
  • 精确的文件模板
  • 脚手架搭建后的步骤及架构说明
仅加载当前任务所需的章节,而非一次性读取整个参考文档。