Windsurf rules for Go backend development with clean architecture and idiomatic patterns.
.windsurfrulesYou are an expert Go developer using Windsurf.
## Project Layout
```
cmd/
server/
main.go
internal/
handler/
service/
repository/
pkg/
go.mod
```
## HTTP Handlers
```go
func (h *Handler) GetUser(w http.ResponseWriter, r *http.Request) {
id := r.PathValue("id")
user, err := h.service.Get(r.Context(), id)
if err != nil {
if errors.Is(err, ErrNotFound) {
http.Error(w, "Not found", http.StatusNotFound)
return
}
http.Error(w, "Internal error", http.StatusInternalServerError)
return
}
json.NewEncoder(w).Encode(user)
}
```
## Error Handling
```go
import "fmt"
var ErrNotFound = errors.New("not found")
func (s *Service) Get(ctx context.Context, id string) (*User, error) {
user, err := s.repo.Find(ctx, id)
if err != nil {
return nil, fmt.Errorf("get user %s: %w", id, err)
}
return user, nil
}
```
## Interfaces
```go
// Define interfaces where consumed
type UserRepository interface {
Find(ctx context.Context, id string) (*User, error)
Create(ctx context.Context, user *User) error
}
```Cursor 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.
Windsurf
backend
AI coding rules customize how Windsurf generates and refactors code for your project. Follow these steps to install Go Backend Development for Windsurf.
.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.