Go Project

Language: Go October 1, 2025

Instruction file for Go projects with idiomatic patterns.

---
applyTo: "**/*.go"
---

# Go Development Instructions (2025)

_Last updated: October 2025_

- Always use the fetch tool to look up the latest Go documentation: https://go.dev/doc
- Follow Effective Go principles for idiomatic code
- Use Go modules for dependency management
- Implement proper error handling (never ignore errors)
- Use goroutines and channels for concurrent operations
- Follow the standard Go project layout: https://github.com/golang-standards/project-layout

**Core Principles:**

- Accept interfaces, return structs
- Keep interfaces small and focused (single method interfaces are common)
- Use defer for cleanup operations
- Implement context.Context for cancellation and timeouts
- Follow Go naming conventions (MixedCaps, not snake_case)
- Use gofmt and golangci-lint for code formatting and linting

**Error Handling:**

- Return errors as the last return value
- Wrap errors with context using fmt.Errorf with %w
- Handle errors at the appropriate level
- Use custom error types when needed

**Concurrency:**

- Use goroutines for concurrent execution
- Communicate via channels, not shared memory
- Use sync.WaitGroup for coordination
- Implement proper context cancellation

**Summary:**

> For all Go work, always use the fetch tool to look up the latest documentation from https://go.dev. Write simple, idiomatic, and efficient Go code.

Go Golang Backend Programming Language