A small REST API to manage tasks. Written in Go with the standard library only (no external frameworks).
Create tasks, list them, read one, update one, and delete one. Each task has a
title, a description, a done flag, and a creation date.
This is my first Go project. I built it to learn the language by hand instead of following a tutorial. It practices:
- HTTP routing and handlers with
net/http - Reading and writing JSON with
encoding/json - Structs, methods, and pointer receivers
- Safe access to shared data with
sync.Mutex - Go error handling (errors are returned as values, not thrown)
Tasks are kept in memory only. When you stop the server, all tasks are gone. This is on purpose: the goal is to learn Go, not to set up a database.
A request flows through three layers, each in its own package:
main.go → handlers/ → store/ → models/
(routing) (HTTP code) (data) (Task type)
- main.go creates the store and the handler, registers the routes, and
starts the server on port
8080. - handlers/ reads the request, calls the store, and writes the JSON answer.
- store/ keeps the tasks in a map and uses a mutex so many requests at the same time are safe.
- models/ defines the
Tasktype.
task-manager/
├── go.mod
├── main.go # wires everything together and starts the server
├── models/
│ └── task.go # the Task struct
├── store/
│ └── store.go # in-memory storage, protected by a mutex
└── handlers/
└── task.go # one HTTP handler per operation
- Go 1.22 or newer (the routing uses patterns like
GET /tasks/{id}, which were added in Go 1.22).
From the project folder:
go run .You should see:
Task Manager API listening on :8080
The server now runs at http://localhost:8080. Keep this terminal open and
use another one to send requests.
| Method | Path | Description | Success status |
|---|---|---|---|
| GET | /tasks |
List all tasks | 200 |
| POST | /tasks |
Create a new task | 201 |
| GET | /tasks/{id} |
Get one task by ID | 200 |
| PUT | /tasks/{id} |
Update a task by ID | 200 |
| DELETE | /tasks/{id} |
Delete a task by ID | 204 |
A task looks like this:
{
"id": 1,
"title": "Learn Go",
"description": "Build a REST API",
"done": false,
"created_at": "2026-06-13T10:00:00Z"
}Make sure the server is running in another terminal first.
# create
curl -X POST http://localhost:8080/tasks -H "Content-Type: application/json" -d '{"title":"Learn Go","description":"Build a REST API"}'
# list
curl http://localhost:8080/tasks
# get one
curl http://localhost:8080/tasks/1
# update
curl -X PUT http://localhost:8080/tasks/1 -H "Content-Type: application/json" -d '{"title":"Learn Go","description":"Done!","done":true}'
# delete
curl -X DELETE http://localhost:8080/tasks/1In PowerShell, curl is not the real curl, so use Invoke-RestMethod:
# create
Invoke-RestMethod -Uri http://localhost:8080/tasks -Method Post -ContentType "application/json" -Body '{"title":"Learn Go","description":"Build a REST API"}'
# list
Invoke-RestMethod -Uri http://localhost:8080/tasks
# get one
Invoke-RestMethod -Uri http://localhost:8080/tasks/1
# update
Invoke-RestMethod -Uri http://localhost:8080/tasks/1 -Method Put -ContentType "application/json" -Body '{"title":"Learn Go","description":"Done!","done":true}'
# delete
Invoke-RestMethod -Uri http://localhost:8080/tasks/1 -Method Delete