A simple RESTful API for managing tasks, built with Go and the Gin web framework.
- List all tasks
- Get a task by ID
- Add a new task
- Update a task
- Delete a task
Each task has the following fields:
id(string): Unique identifiertitle(string): Task titledescription(string): Task detailsduedate(string, RFC3339): Due date/timestatus(string): Task status (e.g., Pending, In Progress, Completed)
- Go 1.18 or later
- Clone this repository or copy the code to your machine.
- Install dependencies:
go mod tidy
- Run the server:
go run main.go
The server will start at http://localhost:8080.
- GET
/tasks - Response: JSON array of all tasks
- GET
/tasks/{id} - Response: JSON object of the task, or
{ "message": "task not found" }if not found
- POST
/tasks - Request Body:
{ "id": "4", "title": "New Task", "description": "Details", "duedate": "2025-07-15T15:04:05Z", "status": "Pending" } - Response: JSON object of the created task
- PUT
/tasks/{id} - Request Body: (fields to update)
- Response: Updated task object or error message
- DELETE
/tasks/{id} - Response:
{ "message": "task removed" }or error message
List all tasks:
curl http://localhost:8080/tasksGet a task by ID:
curl http://localhost:8080/tasks/1Add a new task:
curl -X POST http://localhost:8080/tasks \
-H "Content-Type: application/json" \
-d '{"id":"4","title":"New Task","description":"Details","duedate":"2025-07-15T15:04:05Z","status":"Pending"}'Update a task:
curl -X PUT http://localhost:8080/tasks/1 \
-H "Content-Type: application/json" \
-d '{"title":"Updated Task","description":"Updated details"}'Delete a task:
curl -X DELETE http://localhost:8080/tasks/1main.go— Main application file with all routes and handlers
MIT