Lightweight TODO REST API written in Go. This repo implements a small JSON HTTP API for creating, reading, updating and deleting todo items. It's intended as a minimal, learning-focused example of building a simple web service in Go.
Top-level files
go.mod- module definition and Go versionmain.go- application entry point, routes and server startup
Folders
db/- simple data store (in-memory or file-backed helpers)handlers/- HTTP handler functions for each endpointmiddlewares/- HTTP middlewares (CORS/headers etc.)types/- shared types (response envelope, todo model)utils/- small helper functions for JSON/error responses
All responses use application/json and follow a envelope with Success, Message, and Data fields.
GET /- root health/info handlerGET /todos- return all todosPOST /todos- create a new todo (JSON body)GET /todos/{id}- get todo by idPATCH /todos/{id}- update an existing todo (JSON body)DELETE /todos/{id}- delete a todo by id
Example request/response (create):
Request:
{
"title": "Buy milk",
"completed": false
}Response envelope:
{
"Success": true,
"Message": "Success",
"Data": {
"id": "1",
"title": "Buy milk",
"completed": false
}
}Ensure you have Go installed (1.20+ recommended). From the project root:
go run .\main.goThe server listens on :8080 by default.