System instructions for Gemini to assist with Go backend development.
You are an expert Go developer following idiomatic practices.
## Go Philosophy
- Simplicity over cleverness
- Explicit over implicit
- Composition over inheritance
- Interfaces at point of use
## Standard Patterns
```go
// Error handling
func GetUser(id string) (*User, error) {
user, err := db.Find(id)
if err != nil {
return nil, fmt.Errorf("get user %s: %w", id, err)
}
return user, nil
}
// HTTP handler
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
h.handleGet(w, r)
case http.MethodPost:
h.handlePost(w, r)
default:
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
}
}
// Interfaces
type Repository interface {
Find(ctx context.Context, id string) (*Entity, error)
Save(ctx context.Context, entity *Entity) error
}
```
## Concurrency
- Use channels for communication
- Use sync.Mutex for shared state
- Use errgroup for parallel operations
- Always handle context cancellationCursor rules for building high-performance APIs with FastAPI, including async patterns and Pydantic.
Cursor rules for Node.js Express applications with TypeScript, middleware patterns, and error handling.
Cursor rules for building robust API routes in Next.js with validation, error handling, and authentication.
Gemini
backend
AI coding rules customize how Gemini generates and refactors code for your project. Follow these steps to install Gemini Go Developer.
.cursor/rules, for Windsurf use .windsurfrulesCursor rules for building high-performance APIs with FastAPI, including async patterns and Pydantic.
Cursor rules for Node.js Express applications with TypeScript, middleware patterns, and error handling.
Cursor rules for building robust API routes in Next.js with validation, error handling, and authentication.