Skip to content

shaba5h/go-todo

Repository files navigation

Todo Application

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.

Table of Contents

Features

  • 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

Requirements

  • Go version 1.18 or higher
  • MongoDB version 4.4 or higher

Installation

  1. Clone the repository:
    git clone https://github.com/Shabash4off/go-todo.git
  2. Change to the project directory:
    cd go-todo
  3. Download the required Go modules:
    go mod download

Running the application

  1. Ensure that MongoDB is running on your system.
  2. Create .env and fill it
    cp .env.sample .env
  3. Build and run the application:
    go build -o todo todo/cmd/todo
    ./todo 

Using Docker

You can also run the application using Docker and Docker Compose.

Prerequisites

  • Docker
  • Docker Compose

Build and Run the Application

  1. Build the Docker image:
    docker build -t todo .
  2. Run the Docker container:
    docker run -p 8080:8080 todo

Now the application is running at http://localhost:8080.

Using Docker Compose

  1. Start the application and MongoDB using Docker Compose:
    docker-compose up
  2. Stop the application and MongoDB:
    docker-compose down

API Endpoints

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.

About

This is a simple Todo application built using Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published