From golang
Go项目结构规范:三层架构(API->Impl->State)、全局状态模式、go.mod workspace、禁止Repository接口。设计Go项目架构和目录结构时自动加载。
npx claudepluginhub lazygophers/ccplugin --plugin golangThis skill uses the workspace's default tool permissions.
- **dev** - 开发专家(主要使用者)
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Guides MCP server integration in Claude Code plugins via .mcp.json or plugin.json configs for stdio, SSE, HTTP types, enabling external services as tools.
| 场景 | Skill | 说明 |
|---|---|---|
| 核心规范 | Skills(golang:core) | 核心规范:强制约定、代码格式 |
| 命名规范 | Skills(golang:naming) | 命名规范:Id/Uid/IsActive/CreatedAt |
| 错误处理 | Skills(golang:error) | 错误处理规范:禁止单行 if err |
| 工具库 | Skills(golang:libs) | 优先库规范:stringx/candy/osx |
service/ 目录 - Service 层在 impl/ 中config/ 目录 - 配置在 state/ 中model/ 目录 - 数据模型定义在 state/ 中test/ 目录 - 测试文件在各包中(*_test.go)cmd/ 下有子目录 - 仅放 main.go多模块项目使用 go.work 管理:
# go.work
go 1.23
use (
./server
./shared
./tools
)
server/
├── go.mod
├── go.sum
├── Makefile
├── .golangci.yml
├── config.yaml
├── internal/
│ ├── state/
│ │ ├── table.go # 全局数据模型
│ │ ├── config.go # 配置管理
│ │ ├── database.go # 数据库连接
│ │ ├── cache.go # 缓存连接
│ │ └── init.go # 统一初始化
│ │
│ ├── impl/
│ │ ├── user.go # 用户业务逻辑
│ │ ├── user_test.go # 用户测试
│ │ ├── friend.go # 好友业务逻辑
│ │ └── friend_test.go # 好友测试
│ │
│ ├── api/
│ │ └── router.go # 路由注册
│ │
│ └── middleware/
│ ├── handler.go
│ ├── logger.go
│ ├── auth.go
│ └── error.go
│
└── cmd/
└── main.go
API Layer (Fiber handlers)
|
Service/Impl Layer (业务逻辑)
|
Global State Layer (全局数据访问)
|
Database
var (
User *db.Model[User]
Friend *db.Model[Friend]
Message *db.Model[Message]
)
var Config *AppConfig
var DB *gorm.DB
var Cache *Cache
func UserLogin(ctx *fiber.Ctx, req *LoginReq) (*LoginRsp, error) {
user, err := state.User.NewScoop().
Where("username", req.Username).
First()
if err != nil {
log.Errorf("err:%v", err)
return nil, err
}
return &LoginRsp{User: user}, nil
}
func SetupRoutes(app *fiber.App) {
public := app.Group("/api", middleware.OptionalAuth, middleware.Logger)
public.Post("/Login", impl.ToHandler(impl.UserLogin))
private := app.Group("/api", middleware.Auth, middleware.Logger)
private.Post("/GetUserProfile", impl.ToHandler(impl.GetUserProfile))
}
| AI 可能的理性化解释 | 实际应该检查的内容 | 严重程度 |
|---|---|---|
| "Repository 接口更好测试" | 是否使用全局 State 模式? | 高 |
| "service/ 目录更清晰" | Service 层是否在 impl/ 中? | 高 |
| "config/ 单独管理配置" | 配置是否在 state/ 中? | 中 |
| "model/ 分离数据模型" | 数据模型是否定义在 state/? | 中 |
| "cmd/ 下多个子命令" | cmd/ 是否只有 main.go? | 中 |
| "DI 框架更灵活" | 是否使用全局变量而非依赖注入? | 高 |
internal/state/ 中internal/impl/ 中internal/api/ 中internal/middleware/ 中*_test.go)cmd/ 下只有 main.go,无子目录