An open API service indexing awesome lists of open source software.

https://github.com/jmcarbo/gotemplate

Production-ready Go project template with Clean Architecture, SOLID principles, and comprehensive tooling
https://github.com/jmcarbo/gotemplate

cicd clean-architecture docker go golang solid template testing

Last synced: about 2 months ago
JSON representation

Production-ready Go project template with Clean Architecture, SOLID principles, and comprehensive tooling

Awesome Lists containing this project

README

          

# Go Clean Architecture Template ๐Ÿ—๏ธ

[![CI](https://github.com/jmcarbo/gotemplate/actions/workflows/ci.yml/badge.svg)](https://github.com/jmcarbo/gotemplate/actions/workflows/ci.yml)
[![Tests](https://github.com/jmcarbo/gotemplate/actions/workflows/test.yml/badge.svg)](https://github.com/jmcarbo/gotemplate/actions/workflows/test.yml)
[![Go Version](https://img.shields.io/badge/Go-1.23-blue.svg)](https://golang.org/doc/go1.23)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)

A production-ready Go project template implementing Clean Architecture principles with SOLID design patterns, complete with testing, CI/CD, and project management tools.

## โœจ Features

- **๐Ÿ›๏ธ Clean Architecture** - Clear separation of concerns with domain, use cases, adapters, and infrastructure layers
- **๐Ÿ’Ž SOLID Principles** - Enforced throughout the codebase for maintainable and scalable applications
- **๐Ÿ”„ Template Synchronization** - Keep your projects updated with the latest template improvements
- **๐Ÿ“ฆ Semantic Versioning** - Automated version management with conventional commits
- **๐Ÿงช Comprehensive Testing** - Unit, integration, and template functionality tests
- **๐Ÿณ Docker Support** - Multi-stage builds and docker-compose for local development
- **๐Ÿ”ง Development Tools** - Pre-configured linting, formatting, and git hooks
- **๐Ÿ“š Rich Documentation** - Architecture guides, examples, and best practices
- **๐Ÿค– GitHub Actions** - CI/CD pipelines for testing, building, and releasing

## ๐Ÿš€ Quick Start

### Use this Template

1. Click the "Use this template" button on GitHub
2. Create your new repository
3. Clone and set up your project:

```bash
git clone https://github.com/yourusername/mynewproject.git
cd mynewproject
make setup-project PROJECT_NAME=mynewproject MODULE_PATH=github.com/yourusername/mynewproject
```

### Or Clone Directly

```bash
# Clone the template
git clone https://github.com/jmcarbo/gotemplate.git myproject
cd myproject

# Set up for your project
make setup-project PROJECT_NAME=myproject MODULE_PATH=github.com/yourusername/myproject

# Install tools and dependencies
make install-tools
./scripts/install-hooks.sh

# Start developing
make dev
```

## ๐Ÿ“– Documentation

- [Getting Started Guide](docs/getting-started.md) - Detailed setup instructions
- [Architecture Overview](docs/architecture.md) - Clean Architecture implementation
- [Project Structure](docs/project-structure.md) - Directory layout and conventions
- [Development Guide](docs/development.md) - Development workflow and best practices
- [Template Sync Guide](docs/template-sync.md) - Keep your project updated
- [Examples](docs/examples.md) - Complete feature implementation examples

## ๐Ÿ—๏ธ Project Structure

```
.
โ”œโ”€โ”€ cmd/ # Application entrypoints
โ”œโ”€โ”€ internal/ # Private application code
โ”‚ โ”œโ”€โ”€ domain/ # Business logic and entities
โ”‚ โ”œโ”€โ”€ usecases/ # Application business rules
โ”‚ โ”œโ”€โ”€ adapters/ # Interface adapters (HTTP, gRPC, CLI)
โ”‚ โ””โ”€โ”€ infrastructure/ # External services (DB, cache, etc.)
โ”œโ”€โ”€ pkg/ # Public packages
โ”œโ”€โ”€ docs/ # Documentation
โ”œโ”€โ”€ test/ # Test suites
โ””โ”€โ”€ scripts/ # Utility scripts
```

## ๐Ÿ› ๏ธ Available Commands

```bash
# Development
make run # Run the application
make dev # Run with hot reload
make build # Build the binary
make test # Run all tests
make lint # Run linter
make fmt # Format code

# Template Management
make template-check # Check for template updates
make template-sync # Sync with template updates

# Version Management
make version # Show current version
make release # Create a new release

# Docker
make docker-build # Build Docker image
make docker-run # Run in Docker
```

## ๐Ÿงช Testing

### For Template Users

Your project includes standard Go testing:

```bash
# Run all tests
make test

# Run with coverage
make test-coverage

# Run benchmarks
make benchmark
```

### For Template Development

The template itself is thoroughly tested:

```bash
# Run local template test
./test/test_template.sh

# GitHub Actions runs comprehensive tests:
# - Code quality (lint, format, build)
# - Template instantiation (multiple scenarios)
# - Development workflow
# - Docker builds
# - Version management
# - Pre-commit hooks
# - Full integration tests
```

## ๐Ÿ”„ Keeping Your Project Updated

After creating your project, you can sync updates from the template:

```bash
# Check for updates
make template-check

# Preview changes
make template-sync-dry

# Apply updates
make template-sync
```

## ๐Ÿ“‹ Requirements

- Go 1.23 or higher
- Docker and Docker Compose
- Make
- Git

## ๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request. See our [Contributing Guidelines](CONTRIBUTING.md) for details.

## ๐Ÿ“„ License

This template is available under the MIT License. See [LICENSE](LICENSE) for details.

## ๐Ÿ™ Acknowledgments

- Inspired by Clean Architecture principles by Robert C. Martin
- Built with best practices from the Go community
- Incorporates patterns from Domain-Driven Design

## ๐Ÿ”— Resources

- [Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html)
- [SOLID Principles](https://en.wikipedia.org/wiki/SOLID)
- [Conventional Commits](https://www.conventionalcommits.org/)
- [Semantic Versioning](https://semver.org/)

---

Made with โค๏ธ for the Go community