Go Project CLAUDE.md Template

CLAUDE.md for Go/Golang backend services

Category:templates
Type:template
Difficulty:intermediate
Language:Markdown
go
api
intermediate

Description

Comprehensive CLAUDE.md template for Go projects. Covers project layout, dependency management with Go modules, testing patterns, common libraries (Gin, Echo, GORM), and deployment considerations.

Content

Resource Content
# Go Project

## Overview
Go backend service using standard library and popular frameworks.

## Tech Stack
- Language: Go 1.22+
- Web: Gin/Chi/Echo
- Database: PostgreSQL + sqlc/GORM
- Config: Viper

## Key Commands
```bash
go run ./cmd/server           # Run server
go build ./cmd/server         # Build binary
go test ./...                  # Run all tests
go test -v -cover ./...       # With coverage
go mod tidy                    # Clean deps
golangci-lint run             # Lint code
```

## Project Structure
```
/
├── cmd/
│   └── server/
│       └── main.go           # Entry point
├── internal/
│   ├── api/                  # HTTP handlers
│   ├── domain/               # Business logic
│   ├── repository/           # Data access
│   └── config/               # Configuration
├── pkg/                      # Public packages
├── migrations/               # SQL migrations
└── go.mod                    # Dependencies
```

## Conventions
- Use `internal/` for private packages
- Interface-driven design
- Error wrapping with context
- Structured logging (zerolog/zap)

## Important Notes
- Use context.Context for cancellation
- Graceful shutdown handling
- Use sqlc for type-safe SQL