Files
golang/README.md
0x1d 6ef83e18f8
Some checks failed
CI / Lint (push) Failing after 45s
CI / Test (push) Failing after 10s
CI / Build (push) Has been skipped
CI / Docker Build (push) Has been skipped
feat: initialize golang project template with docker and ci/cd
2026-01-12 10:47:04 +01:00

71 lines
1.4 KiB
Markdown

# 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.go` implements signal handling and context cancellation.
- **Structured Logging**: Uses `log/slog`.
- **Docker**: Multi-stage `Dockerfile` using `distroless` for secure, small images.
- **CI/CD**: GitHub Actions for linting, testing, building, and releasing (with GoReleaser).
- **Tooling**: `Makefile` for common tasks and `golangci-lint` configuration.
## Prerequisites
- [Go](https://go.dev/) 1.23+
- [Docker](https://www.docker.com/)
- [Make](https://www.gnu.org/software/make/)
## Getting Started
### Build and Run
```bash
# Build binary
make build
# Run application
make run
```
### Testing
```bash
make test
```
### Linting
```bash
make lint
```
## Docker
Build the Docker image:
```bash
make docker-build
```
Run the container:
```bash
docker run --rm -p 8080:8080 app:latest
```
## CI/CD
The project includes GitHub Actions workflows:
- **CI (`ci.yml`)**: Runs on `main` and 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.