This is a simple Todo application built using Go. The application allows users to create, read, update, and delete todo items. It uses MongoDB as the storage backend, and is structured with separate packages for handling HTTP requests, processing business logic, and interacting with the database.
- Create a new todo item
- Retrieve all todo items
- Retrieve a specific todo item by ID
- Update a todo item by ID
- Delete a todo item by ID
- Clone the repository:
git clone https://github.com/Shabash4off/go-todo.git
- Change to the project directory:
cd go-todo - Download the required Go modules:
go mod download
- Ensure that MongoDB is running on your system.
- Create .env and fill it
cp .env.sample .env
- Build and run the application:
go build -o todo todo/cmd/todo ./todo
You can also run the application using Docker and Docker Compose.
- Docker
- Docker Compose
- Build the Docker image:
docker build -t todo . - Run the Docker container:
docker run -p 8080:8080 todo
Now the application is running at http://localhost:8080.
- Start the application and MongoDB using Docker Compose:
docker-compose up
- Stop the application and MongoDB:
docker-compose down
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/todo/create | Create a new todo item |
| GET | /api/todos | Retrieve all todo items |
| GET | /api/todo/id?id={id} | Retrieve a todo item by ID |
| PUT | /api/todo/update?id={id} | Update a todo item by ID |
| DELETE | /api/todo/delete?id={id} | Delete a todo item by ID |
| Note: Replace {id} with the actual ID of the todo item in the URL when using the specific item endpoints. |