| name | go-reviewer |
| description | Review Go code against Chatlayer team conventions and Go best practices. Use when: (1) reviewing Go code changes, (2) checking Go PRs/MRs, (3) validating Go patterns, (4) ensuring Go idioms. Triggers: 'review go', 'go code review', 'check go code', 'go patterns', 'review *.go'. |
| compatibility | opencode |
Go Code Reviewer
Review Go code against Chatlayer team conventions derived from actual MR reviews and codebase patterns.
Quick Review Checklist
Naming (High Priority)
| Pattern | Correct | Incorrect |
|---|
| Receiver names | func (a *API) Get() | func (api *API) Get() |
| Acronyms | API, ID, URL, HTTP | Api, Id, Url, Http |
| Mutex suffix | streamUpdateMu | streamLock, streamMutex |
| Interface location | In consuming package | In implementing package |
Error Handling
return errx.Wrap(err, "fetching user", errx.Fields{"userId": id})
return err
func process() (result Result, retErr error) {
defer func() { if retErr != nil { cleanup() } }()
}
Context & Tracing
func (a *API) Handle(w http.ResponseWriter, req *http.Request) {
span, ctx := tracer.StartSpanFromContext(req.Context(), "api.handle")
defer span.Finish()
result, err := a.service.Process(ctx, input)
if err != nil {
span.Finish(tracer.WithError(err))
logger.Error(ctx, errx.Wrap(err, "processing failed"))
return
}
}
Imports (Order Matters)
import (
"context"
"fmt"
"github.com/gorilla/mux"
"chatlayer.ai/common/errx"
"chatlayer.ai/common/logger"
)
Review Categories
1. Idiomatic Go
2. Error Handling
3. Logging
4. Concurrency
5. HTTP Handlers
6. Testing
Anti-Patterns to Flag
Critical (Block MR)
ctx = context.WithoutCancel(ctx)
log.Fatal(err)
_ = dangerousOperation()
High Priority
if err != nil {
}
if len(items) > 100 {
func (controller *ConferenceController) Handle()
Medium Priority
func GetLease(ctx context.Context, id string) (*Lock, error)
func GetLease(ctx context.Context, id string, timeout time.Duration) (*Lock, error)
active_conferences sync.Map
pending_conferences sync.Map
conferences sync.Map
replicas sync.Map
Comment Format
(AI assisted) **[Category]**: Issue description.
**Current**:
`problematic_code()`
**Suggested**:
`improved_code()`
**Why**: Brief explanation of the improvement.
Categories: Go Idiom, Error Handling, Concurrency, Performance, Testing, Style
Reference Files
For detailed patterns, see: