Debugging et maintenancesource GitHub
Revue de code Go
/go-reviewAnalyse le code Go pour détecter bugs, risques de sécurité, mauvaises pratiques et problèmes de maintenabilité.
// contenu du skill
description: Comprehensive Go code review for idiomatic patterns, concurrency safety, error handling, and security. Invokes the go-reviewer agent.
Go Code Review
This command invokes the go-reviewer agent for comprehensive Go-specific code review.
What This Command Does
- Identify Go Changes: Find modified
.gofiles viagit diff - Run Static Analysis: Execute
go vet,staticcheck, andgolangci-lint - Security Scan: Check for SQL injection, command injection, race conditions
- Concurrency Review: Analyze goroutine safety, channel usage, mutex patterns
- Idiomatic Go Check: Verify code follows Go conventions and best practices
- Generate Report: Categorize issues by severity
When to Use
Use /go-review when:
- After writing or modifying Go code
- Before committing Go changes
- Reviewing pull requests with Go code
- Onboarding to a new Go codebase
- Learning idiomatic Go patterns
Review Categories
CRITICAL (Must Fix)
- SQL/Command injection vulnerabilities
- Race conditions without synchronization
- Goroutine leaks
- Hardcoded credentials
- Unsafe pointer usage
- Ignored errors in critical paths
HIGH (Should Fix)
- Missing error wrapping with context
- Panic instead of error returns
- Context not propagated
- Unbuffered channels causing deadlocks
- Interface not satisfied errors
- Missing mutex protection
MEDIUM (Consider)
- Non-idiomatic code patterns
- Missing godoc comments on exports
- Inefficient string concatenation
- Slice not preallocated
- Table-driven tests not used
Automated Checks Run
bash
# Static analysis
go vet ./...
# Advanced checks (if installed)
staticcheck ./...
golangci-lint run
# Race detection
go build -race ./...
# Security vulnerabilities
govulncheck ./...Example Usage
text
User: /go-review
Agent:
# Go Code Review Report
## Files Reviewed
- internal/handler/user.go (modified)
- internal/service/auth.go (modified)
## Static Analysis Results
✓ go vet: No issues
✓ staticcheck: No issues
## Issues Found
[CRITICAL] Race Condition
File: internal/service/auth.go:45
Issue: Shared map accessed without synchronizationvar cache = map[string]*Session{} // Concurrent access!
func GetSession(id string) *Session {
return cache[id] // Race condition
}
Fix: Use sync.RWMutex or sync.Mapvar (
cache = map[string]*Session{}
cacheMu sync.RWMutex
)
func GetSession(id string) *Session {
cacheMu.RLock()
defer cacheMu.RUnlock()
return cache[id]
}
[HIGH] Missing Error Context
File: internal/handler/user.go:28
Issue: Error returned without contextreturn err // No context
Fix: Wrap with contextreturn fmt.Errorf("get user %s: %w", userID, err)
## Summary
- CRITICAL: 1
- HIGH: 1
- MEDIUM: 0
Recommendation: FAIL: Block merge until CRITICAL issue is fixedApproval Criteria
| Status | Condition |
|---|---|
| PASS: Approve | No CRITICAL or HIGH issues |
| WARNING: Warning | Only MEDIUM issues (merge with caution) |
| FAIL: Block | CRITICAL or HIGH issues found |
Integration with Other Commands
- Use
/go-testfirst to ensure tests pass - Use
/go-buildif build errors occur - Use
/go-reviewbefore committing - Use
/code-reviewfor non-Go specific concerns
Related
- Agent:
agents/go-reviewer.md - Skills:
skills/golang-patterns/,skills/golang-testing/
// source originale publique
affaan-m/ECC/commands/go-review.md
Licence : MIT License
Projet indépendant, non affilié à Anthropic. Ce skill reste la propriété de son auteur original.