This is a simple CRUD (Create, Read, Update, Delete) application built in Go using the Gin Web Framework. The application manages a list of todos
, allowing users to create, read, update, and delete todo
items.
- Create a Todo: Add a new
todo
item with a ID, description, and completion status. - Read Todos: Retrieve the list of all
todos
or get details for a specifictodo
. - Update a Todo: Edit an existing
todo
by updating its description and/or completion status. - Delete a Todo: Remove a
todo
item from the list.
GET /todos
- Retrieves the full list of todos.POST /todos
- Creates a new todo item.GET /todos/:id
- Retrieves details of a specific todo by ID.PATCH /todos/:id
- Toggles the completion status of a todo.PUT /todos/:id
- Updates the description and/or completion status of a specific todo.DELETE /todos/:id
- Deletes a specific todo by ID.
- Go (version 1.18 or higher)
- Gin Web Framework
-
Clone the repository:
git clone https://github.com/aleksandr-slobodian/go-simple-crud cd go-simple-crud
-
Install dependencies:
go mod download
-
Run the application:
with go:
go run main.go
with Air - Live reload:
air
-
Create a new todo:
curl -X POST -H "Content-Type: application/json" -d '{"item": "Buy groceries", "completed": false}' http://localhost:9090/todos
-
Retrieve all todos:
curl http://localhost:9090/todos
-
Retrieve a specific todo:
curl http://localhost:9090/todos/1
-
Update a todo:
curl -X PUT -H "Content-Type: application/json" -d '{"item": "Buy groceries", "completed": true}' http://localhost:9090/todos/1
-
Update todo's completed status:
curl -X PUTCH http://localhost:9090/todos/1
-
Delete a todo:
curl -X DELETE http://localhost:9090/todos/1
This project is licensed under the MIT License.