A lightweight REST API for managing todos, built with Go and SQLite.
- Full CRUD operations (Create, Read, Update, Delete)
- SQLite database for persistent storage
- CORS enabled for cross-origin requests
- Health check endpoint
# Install dependencies
go mod download
# Run the server
go run main.goThe server will start on http://localhost:8080 (or the port specified in PORT env variable).
| Method | Endpoint | Description |
|---|---|---|
| GET | /todos | List all todos |
| GET | /todos/{id} | Get a single todo |
| POST | /todos | Create a new todo |
| PATCH | /todos/{id} | Update a todo |
| DELETE | /todos/{id} | Delete a todo |
| GET | /health | Health check |
curl -X POST http://localhost:8080/todos \
-H "Content-Type: application/json" \
-d '{"text": "Buy groceries"}'curl http://localhost:8080/todoscurl -X PATCH http://localhost:8080/todos/1 \
-H "Content-Type: application/json" \
-d '{"done": true}'curl -X DELETE http://localhost:8080/todos/1| Variable | Default | Description |
|---|---|---|
| PORT | 8080 | Server port |
Create a .env file to override defaults:
PORT=3000- Go 1.25+
- SQLite (modernc.org/sqlite)
- CORS (rs/cors)
- godotenv