This is a showcase project for a Go service implementing cloud-native practices, using a link shortener as the example application.
- Go with Gin http router
- OpenAPI specification with oapi-codegen
- Redis for URL storage
- Zap for structured json logging
- OpenTelemetry/Jaeger for distributed tracing
- Testcontainers for integration testing
- Environment-based configuration
- ko for multi-platform Docker images
- GitHub Actions for CI
- GitHub Packages publishing
-
Clone the repository:
gh repo clone enleur/shrink -
Install dependencies:
go mod download -
Set up environment variables (see
config.gofor required variables). -
Generate API-related code:
go generate ./... -
Run the service:
go run cmd/server/main.go -
The service will be available at
http://localhost:8080(or the configured port).
The API is defined using OpenAPI specification. The main endpoints are:
POST /shorten: Shorten a URLGET /{shortCode}: Redirect to the original URL
API-related code is generated using go generate with oapi-codegen.
To run the test suite:
go test -v ./...Note: Docker is required for integration tests using test containers.