Go Task API is my third project developed in Go, created with the goal of consolidating knowledge in the language and exploring its fundamental patterns. This repository serves as study material and personal reference, focusing on an implementation strictly based on the standard library (net/http).
The project implements architectural patterns such as Repository and Dependency Injection, ensuring modularity and testability in environments with multiple providers (Memory and PostgreSQL).
This project was built to absorb essential engineering concepts with Go:
- Standard Library: Using
net/httpwithout external frameworks (Gin, Echo). - Dependency Injection: Decoupling layers through interfaces.
- Dual Persistence: Implementation of repositories in both memory and PostgreSQL.
- Middlewares: Creation of security (Auth) and resilience (Recovery) layers.
- DevOps & CI/CD: Orchestration with Docker and automation with GitHub Actions.
Create a Task:
curl -i -X POST \
-H "X-API-Key: secret-key" \
-H "Content-Type: application/json" \
-d '{"title": "Documentation Refactor", "description": "Implement high-quality docs", "status": "doing"}' \
http://localhost:8080/tasksList All Tasks:
curl -i -H "X-API-Key: secret-key" http://localhost:8080/tasks| Technology | Role |
|---|---|
| Go 1.22+ | Core runtime and standard library (net/http) |
| PostgreSQL | Persistent data storage |
| Docker | Containerization and infrastructure orchestration |
| GitHub Actions | Automated CI/CD pipeline |
- Go >= 1.22
- Docker & Docker Compose (for PostgreSQL)
- Make (optional, but recommended)
# 1. Clone the repository
git clone https://github.com/ESousa97/apigotask.git
cd apigotask
# 2. Start the database
docker-compose up -d
# 3. Build and Run
make run| Target | Description |
|---|---|
make build |
Compiles the project into bin/apigotask |
make run |
Builds and executes the server |
make test |
Runs all unit and integration tests |
make clean |
Removes build artifacts and binaries |
make help |
Displays all available commands |
The project follows a modular structure separated by logical responsibilities, ensuring that business rules remain decoupled from infrastructure details.
graph TD
Client[HTTP Client] --> Mux[net.ServeMux]
Mux --> Handler[internal/handler]
Handler --> RepoInterface[internal/repository Interface]
RepoInterface --> Postgres[internal/repository/PostgreSQL]
RepoInterface --> Memory[internal/repository/Memory]
subgraph "Domain Layer"
Task[internal/domain/Task]
end
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/tasks |
List all available tasks | Yes |
POST |
/tasks |
Create a new task entry | Yes |
GET |
/tasks/{id} |
Retrieve a specific task | Yes |
PUT |
/tasks/{id} |
Update an existing task | Yes |
DELETE |
/tasks/{id} |
Remove a task | Yes |
View full documentation at pkg.go.dev/github.com/ESousa97/apigotask.
| Variable | Description | Type | Default |
|---|---|---|---|
APP_PORT |
Port where the server listens | int | 8080 |
DB_URL |
PostgreSQL connection string | string | postgres://postgres:password@localhost:5433/taskdb?sslmode=disable |
Track the project's evolution stages:
- Phase 1: Foundation — In-Memory persistence core.
- Phase 2: Persistence — PostgreSQL integration with Docker.
- Phase 3: Security — Middleware implementation (Auth & Recovery).
- Phase 4: Patterns — Repository Pattern & Dependency Injection.
- Phase 5: Governance — CI/CD, Professional Documentation and Badges.
Interested in collaborating? Check our CONTRIBUTING.md for code standards and PR process.
This project is licensed under the MIT License — see the LICENSE file for details.
