用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill golang-mvc命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | golang-mvc |
| description | > Use when this capability is needed. |
Go MVC implementation conventions for feature work and refactoring. This skill guides code generation and actively enforces layer boundaries — it modifies and refactors code that violates MVC conventions.
| Layer | Package | Responsibility | May import | Must NOT import |
|---|---|---|---|---|
| Handler | handler/ | HTTP entry point; orchestrate business rules; validate and map input/output | service/, model/, validation/ | config/, DB drivers, repository/ |
| Service | service/ | Thin adapter over external APIs, queues, caches | model/, config/ | handler/ |
| Repository | repository/ | DB access only; returns domain objects | model/, config/ | handler/, service/ |
| Model | model/ | Pure data: domain structs + conversion methods (ToDTO, FromRow) | nothing internal | handler/, service/, repository/ |
| Validation | validation/ | Named validators for domain rules | model/ | handler/, service/ |
| Config | config/ | Load env/files; construct and wire concrete types | all | — |
Build in this order. Do not skip steps.
model/)model/ (use model (singular) as the default package for domain models, unless there are more than 30 models, in which case they must be split into domain-specific packages).ToDTO(), FromRow()).repository/ package. One file per aggregate root.service/ package. Retry + timeout logic only; no business decisions.handler/)func NewUserHandler(getter UserGetter, notifier NotifySender, log Logger) *UserHandlerRegisterRoutes(r *gin.RouterGroup) method; never inline in main.go.validation/)Validate() error method.ValidateCreateOrderRequest, not validate.validation.Error{Field: "...", Reason: "..."} — never raw strings.main.go or bootstrap.go)main.go/bootstrap.go.config.Default() from github.com/bizshuk/gosdk, falling back to raw viper manual setup only if the SDK is not supported/available.Interfaces are defined where consumed, not where implemented.
// In handler/user.go — NOT in repository/user.go
type userGetter interface {
GetByID(ctx context.Context, id string) (*model.User, error)
}
This means handler tests can mock the interface without importing the repository package, breaking the import cycle and enabling true unit isolation.
| Dependency count | Pattern |
|---|---|
| ≤ 4 deps | Plain constructor params |
| 5+ deps | HandlerOptions struct |
| Many optional knobs | Functional options ...Option |
fmt.Errorf("handler.GetUser: %w", err)var ErrNotFound = errors.New("not found")SCREAMING_SNAKE_CASE (e.g. MAX_RETRIES, DEFAULT_TIMEOUT).ctx context.Context is always the first parameter of any function that does I/Octx in a structctx, cancel := context.WithTimeout(ctx, cfg.DBTimeout); defer cancel()| Layer | Test approach |
|---|---|
| Handler | Mock all interfaces; use httptest.NewRecorder(); assert status + response body |
| Repository | Use sqlmock or a real test DB via docker-compose; never mock the DB driver itself |
| Service | Mock external HTTP/gRPC clients with interface mocks |
| Validation | Table-driven tests required; cover valid, missing, and out-of-range inputs |
All test files: _test.go suffix, same package as the code under test (prefer white-box
tests for internal helpers, _test package suffix for public API contracts).
Source: BizShuk/gosdk — distributed by TomeVault.