-
Notifications
You must be signed in to change notification settings - Fork 0
hyp generate.md
maoxiaoyue edited this page Apr 14, 2026
·
1 revision
生成遵循 HypGo 慣例的 boilerplate 程式碼。
hyp generate [type] [name] hyp generate [type] [name] -m <module-name>
| 類型 | 說明 | 產出位置 | 適用 |
|---|---|---|---|
controller |
Controller + Schema Router + Middleware |
app/controllers/ + app/routers/
|
Web |
model |
Bun ORM Model + Req/Resp struct | app/models/ |
全部 |
service |
業務邏輯 + Error Catalog | app/services/ |
全部 |
command |
Cobra 子命令 | app/commands/ |
CLI |
view |
Fyne GUI 視圖 | app/views/ |
Desktop |
| Flag | 說明 | 預設值 |
|---|---|---|
-m, --module |
Go module 名稱 | 自動從 go.mod 偵測 |
hyp generate controller user
一次產生 4 個檔案:
app/controllers/user_controller.go ← Handler(List/Create/Get/Update/Delete)
app/routers/user.go ← Schema 路由(含 Input/Output)
app/routers/router.go ← Setup() 總入口(首次才生成)
app/routers/middleware.go ← 中間件配置(首次才生成)
hyp generate model user
產生 5 個 struct:User(DB)、CreateUserReq、UpdateUserReq、UserResp、UserListResp
hyp generate service user
產生含 Error Catalog 的 service 骨架。
v0.8.5+command(CLI)和view(Desktop)生成類型為 v0.8.5 新增功能。
hyp generate command process hyp generate command export
產生 Cobra 子命令,自動在 init() 註冊到 rootCmd。
hyp generate view settings hyp generate view dashboard
產生 Fyne GUI 視圖,含 fyne.Window 參數和基本佈局。
# Web hyp generate model user # 1. 先定義資料結構 hyp generate controller user # 2. 生成 handler + router hyp generate service user # 3. 生成業務邏輯 # CLI hyp generate command process # 直接生成子命令 # Desktop hyp generate view settings # 直接生成視圖
- 名稱驗證:只允許
[a-zA-Z][a-zA-Z0-9_]* - 不覆蓋已存在的檔案
- Module 名稱自動偵測
- hyp new — 建立專案
- hyp context — 生成的 Schema 路由會出現在 manifest 中
設計文件
套件
- config — 設定
- context — 請求上下文
- router — 路由器
- server — 伺服器
- middleware — 中介層
- websocket — WebSocket
- hidb — 資料庫 ORM
- hidb/cassandra — Cassandra
- logger — 日誌
- json — JSON 處理
- grpc — gRPC
AI 協作工具鏈
- schema — Schema-first 路由
- manifest — 專案 Manifest
- contract — Contract Testing
- errors — Typed Error Catalog
- migrate — Migration Diff
- scaffold — 智慧 Scaffold
- airules — AI Rules
CLI 命令
- hyp 總覽
- hyp new
- hyp api
- hyp run
- hyp restart
- hyp generate
- hyp migrate
- hyp context
- hyp ai-rules
- hyp chkcomment
- hyp impact
- hyp docker
- hyp health
- hyp version
- hyp difflog
Design Docs
Packages
- config — Configuration
- context — Request Context
- router — Router
- server — Server
- middleware — Middleware
- websocket — WebSocket
- hidb — Database ORM
- hidb/cassandra - Cassandra 5.0
- logger — Logger
- json — JSON
- grpc — gRPC
AI Collaboration Toolchain
- schema — Schema-first Routing
- manifest — Project Manifest
- contract — Contract Testing
- errors — Typed Error Catalog
- migrate — Migration Diff
- scaffold — Smart Scaffold
- airules — AI Rules
CLI Commands