scaffold

command
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 8 Imported by: 0

README

oapi-hinge CLI(scaffold)

生成 Go API 项目骨架:统一 Handler 模板 + 原生 Gin 运行时 + 开发期 OpenAPI 文档生成(-tags openapi 隔离构建,release 零开发依赖)。

用法

# 从仓库根目录
go run ./scaffold create myapp -m github.com/you/myapp

# 或直接用发布版本
go run github.com/EdSan845D/oapi-hinge/scaffold@latest create myapp -m github.com/you/myapp

flags:-m 模块路径、--no-tidy 跳过依赖拉取、--force 覆盖目录。

生成物

统一 Handler 模板(app/handlers)+ 路由注册表(app/routes)+ 原生 Gin 运行时 + main_doc.go 文档入口(-tags openapi)。

生成的 go.mod 直接依赖单模块 github.com/EdSan845D/oapi-hinge(模板内置 v0.2.0,可按需调整),随后自动执行 go mod tidy。使用方式见 docs/MANUAL.md

Documentation

Overview

oapi-hinge —— 生成 Go API 项目骨架的命令行工具(类似 pnpm create vite)。

用法:

oapi-hinge create myapp                    # 生成 ./myapp,module 名 = myapp
oapi-hinge create myapp -m github.com/me/myapp
oapi-hinge create myapp --no-tidy          # 跳过 go mod tidy
oapi-hinge create myapp --force            # 覆盖已存在的目录

生成产物:统一 Handler 模板 + 单一路由注册表 + 原生 Gin 运行时 + 文档生成(构建期隔离)。 内置示例业务(用户 CRUD + 文件下载 + 健康检查),删掉 app/handlers 下的示例即可开始写自己的业务。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL