cursor / claude rules

Go Cursor Rules

Cursor rules for Go (Golang) projects. Idiomatic Go patterns, error handling, package structure.
by cache.directory updated May 18, 2026 CC-BY-4.0

## what it does

.cursorrules for Go

# Go Project Rules

## Style
- Follow Effective Go and Go Code Review Comments
- Use gofmt/goimports formatting
- Error wrapping with fmt.Errorf("operation: %w", err)
- No naked returns
- Exported functions MUST have doc comments

## Error Handling
- Always handle errors explicitly (no _ for errors)
- Use errors.Is() and errors.As() for comparison
- Custom error types implement error interface
- Return errors, don't panic (except truly unrecoverable)

## Package Structure
- cmd/ for entry points
- internal/ for private packages
- pkg/ for public libraries (if any)
- One package per directory

## Testing
- Table-driven tests with t.Run()
- Testify for assertions
- Mocks in _test.go files
- Use t.Parallel() for independent tests

## Concurrency
- Prefer channels over mutexes for communication
- Always use context.Context for cancellation
- Use errgroup for concurrent operations with error handling

## embed this badge

cache ✓ in cache.directory
![cached](https://cache.directory/badge/golang-cursor-rules.svg)