Golang Project Template
A production-ready Go project template with Docker builds, CI/CD pipelines, and best practices.
Features
- Standard Layout: Follows Go project layout standards (
cmd,internal). - Graceful Shutdown:
main.goimplements signal handling and context cancellation. - Structured Logging: Uses
log/slog. - Docker: Multi-stage
Dockerfileusingdistrolessfor secure, small images. - CI/CD: GitHub Actions for linting, testing, building, and releasing (with GoReleaser).
- Tooling:
Makefilefor common tasks andgolangci-lintconfiguration.
Prerequisites
Getting Started
Build and Run
# Build binary
make build
# Run application
make run
Testing
make test
Linting
make lint
Docker
Build the Docker image:
make docker-build
Run the container:
docker run --rm -p 8080:8080 app:latest
CI/CD
The project includes GitHub Actions workflows:
- CI (
ci.yml): Runs onmainand PRs. Validates formatting, linting, tests, and builds. - Release (
release.yml): Runs on tags (v*). Creates a GitHub Release and pushes the Docker image to GHCR.
Project Structure
cmd/app: Main application entry point.internal: Private application code.build: Build artifacts..github: CI/CD workflows.
1.0.0
Latest
Languages
Go
46%
Dockerfile
36.6%
Makefile
17.4%