mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-14 22:13:41 +08:00
Revert "feat(ecc): prune plugin 43→12 items, promote 7 rules to .claude/rules/ (#245)"
This reverts commit 1bd68ff534.
This commit is contained in:
26
docs/zh-CN/rules/golang/coding-style.md
Normal file
26
docs/zh-CN/rules/golang/coding-style.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Go 编码风格
|
||||
|
||||
> 本文件在 [common/coding-style.md](../common/coding-style.md) 的基础上,扩展了 Go 语言的特定内容。
|
||||
|
||||
## 格式化
|
||||
|
||||
* **gofmt** 和 **goimports** 是强制性的 —— 无需进行风格辩论
|
||||
|
||||
## 设计原则
|
||||
|
||||
* 接受接口,返回结构体
|
||||
* 保持接口小巧(1-3 个方法)
|
||||
|
||||
## 错误处理
|
||||
|
||||
始终用上下文包装错误:
|
||||
|
||||
```go
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create user: %w", err)
|
||||
}
|
||||
```
|
||||
|
||||
## 参考
|
||||
|
||||
查看技能:`golang-patterns` 以获取全面的 Go 语言惯用法和模式。
|
||||
11
docs/zh-CN/rules/golang/hooks.md
Normal file
11
docs/zh-CN/rules/golang/hooks.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Go 钩子
|
||||
|
||||
> 本文件通过 Go 特定内容扩展了 [common/hooks.md](../common/hooks.md)。
|
||||
|
||||
## PostToolUse 钩子
|
||||
|
||||
在 `~/.claude/settings.json` 中配置:
|
||||
|
||||
* **gofmt/goimports**:编辑后自动格式化 `.go` 文件
|
||||
* **go vet**:编辑 `.go` 文件后运行静态分析
|
||||
* **staticcheck**:对修改的包运行扩展静态检查
|
||||
39
docs/zh-CN/rules/golang/patterns.md
Normal file
39
docs/zh-CN/rules/golang/patterns.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Go 模式
|
||||
|
||||
> 本文档在 [common/patterns.md](../common/patterns.md) 的基础上扩展了 Go 语言特定的内容。
|
||||
|
||||
## 函数式选项
|
||||
|
||||
```go
|
||||
type Option func(*Server)
|
||||
|
||||
func WithPort(port int) Option {
|
||||
return func(s *Server) { s.port = port }
|
||||
}
|
||||
|
||||
func NewServer(opts ...Option) *Server {
|
||||
s := &Server{port: 8080}
|
||||
for _, opt := range opts {
|
||||
opt(s)
|
||||
}
|
||||
return s
|
||||
}
|
||||
```
|
||||
|
||||
## 小接口
|
||||
|
||||
在接口被使用的地方定义它们,而不是在它们被实现的地方。
|
||||
|
||||
## 依赖注入
|
||||
|
||||
使用构造函数来注入依赖:
|
||||
|
||||
```go
|
||||
func NewUserService(repo UserRepository, logger Logger) *UserService {
|
||||
return &UserService{repo: repo, logger: logger}
|
||||
}
|
||||
```
|
||||
|
||||
## 参考
|
||||
|
||||
有关全面的 Go 模式(包括并发、错误处理和包组织),请参阅技能:`golang-patterns`。
|
||||
28
docs/zh-CN/rules/golang/security.md
Normal file
28
docs/zh-CN/rules/golang/security.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Go 安全
|
||||
|
||||
> 此文件基于 [common/security.md](../common/security.md) 扩展了 Go 特定内容。
|
||||
|
||||
## 密钥管理
|
||||
|
||||
```go
|
||||
apiKey := os.Getenv("OPENAI_API_KEY")
|
||||
if apiKey == "" {
|
||||
log.Fatal("OPENAI_API_KEY not configured")
|
||||
}
|
||||
```
|
||||
|
||||
## 安全扫描
|
||||
|
||||
* 使用 **gosec** 进行静态安全分析:
|
||||
```bash
|
||||
gosec ./...
|
||||
```
|
||||
|
||||
## 上下文与超时
|
||||
|
||||
始终使用 `context.Context` 进行超时控制:
|
||||
|
||||
```go
|
||||
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
defer cancel()
|
||||
```
|
||||
25
docs/zh-CN/rules/golang/testing.md
Normal file
25
docs/zh-CN/rules/golang/testing.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Go 测试
|
||||
|
||||
> 本文档在 [common/testing.md](../common/testing.md) 的基础上扩展了 Go 特定的内容。
|
||||
|
||||
## 框架
|
||||
|
||||
使用标准的 `go test` 并采用 **表格驱动测试**。
|
||||
|
||||
## 竞态检测
|
||||
|
||||
始终使用 `-race` 标志运行:
|
||||
|
||||
```bash
|
||||
go test -race ./...
|
||||
```
|
||||
|
||||
## 覆盖率
|
||||
|
||||
```bash
|
||||
go test -cover ./...
|
||||
```
|
||||
|
||||
## 参考
|
||||
|
||||
查看技能:`golang-testing` 以获取详细的 Go 测试模式和辅助工具。
|
||||
Reference in New Issue
Block a user