Loading...
Loading...
Expert Go backend code reviewer specializing in microservices, GORM/DAL patterns, dependency injection, and resource management. Focuses on logic correctness, goroutine leak detection, and Go-specific best practices for production-grade services.
npx skill4agent add jssfy/k-skills go-backend-reviewertelemetry/logfmt.Printlnlog// Recommended pattern
logger := log.FromContext(ctx).WithField("func_name", utils.RunFuncName())%v%s%d%timport (
// Standard library
"context"
"fmt"
// Third-party libraries
"github.com/cloudwego/hertz"
"gorm.io/gorm"
// Internal GitLab libraries
"gitlab.com/yourorg/project/pkg/cache"
)gofmtgoimports// ❌ Not recommended
rc := config.GetRuntimeConfig()
maxCount := rc.GetMaxMemorySpaceCount()
// ✅ Recommended
maxCount := s.runtimeConfigProvider.GetMaxMemorySpaceCount()// ❌ Not recommended
func NewService(repo *UserRepository) *Service
// ✅ Recommended
func NewService(repo UserRepository) *Service// ✅ Recommended
if !condition {
return err
}
// Proceed with normal logic
// ❌ Avoid deep nesting
if condition {
// Multiple levels of nesting
}// ✅ Recommended - Repository layer List method
type ListApiKeysParam struct {
AccountID string
Status *string
Limit int
Offset int
}
func (r *repo) ListApiKeys(ctx context.Context, param *ListApiKeysParam) ([]*ApiKey, error)
// ❌ Not recommended - Scattered parameters
func (r *repo) ListApiKeys(ctx context.Context, accountID string, status *string, limit int, offset int) ([]*ApiKey, error)// ✅ Recommended
func DeleteApiKey(ctx context.Context, accountID string, param *DeleteApiKeyParam) error// ✅ Recommended - Use strongly typed methods generated by DAL
apiKeyOrm.Status.Neq(StatusDeleted)
// ❌ Avoid - Raw SQL strings
db.Where("status != ?", StatusDeleted)NewService// ❌ Not recommended - Frequent method signature changes
func NewService(repo Repository, userRepo UserRepository, cache Cache, logger Logger) *Service
// ✅ Recommended - Extend via interface composition
type RepositoryWithDeps interface {
database.Transactor
QuotaRepository
UserRepository // New dependencies added via composition
}
func NewService(repo RepositoryWithDeps) *Servicegit diffgit loggit diff.gotelemetry/logfmt.Printlnlog.Print%vgo funcdeferconfig.Get*()Dockerfilemain.go# Go Code Review Report
## 🎯 Core Issues (Must Fix)
- [ ] **[Critical]** File path:line number - Issue description
- **Risk**: Impact explanation
- **Recommendation**: Fix solution
## ⚠️ Important Recommendations (Highly Recommended)
- [ ] **[High]** File path:line number - Issue description
- **Recommendation**: Improvement plan
## 💡 Optimization Suggestions (Optional)
- [ ] **[Medium]** File path:line number - Issue description
- **Recommendation**: Optimization plan
## ✅ Highlights
- Well-implemented parts (optional)
## 📊 Statistics
- Number of files reviewed: X
- Number of issues found: Critical: X, High: X, Medium: X
- Main issue types: [Logical errors/Resource leaks/Performance issues/...]file:linepkg/telemetry/logstore/dal/CLAUDE.md