Giter VIP home page Giter VIP logo

go-crud-api-project's Introduction

Go-CRUD-API-Project

Inventory Management

This project is a Go-based CRUD API for inventory management of products. It utilizes MySQL for persistent data storage and provides API endpoints for managing your inventory through:

  • GET: Retrieve information about existing products.
  • POST: Create new products and add them to your inventory.
  • PUT: Update existing product details in your inventory.
  • DELETE: Remove unwanted products from your inventory.

This API empowers you to manage your product stock efficiently, facilitating tasks like:

  • Tracking product quantities and prices.
  • Adding new products to your inventory.
  • Updating existing product details like descriptions or variations.
  • Removing or archiving products no longer available.

This is a simple yet powerful tool for developers and individuals wanting to build applications with inventory management capabilities.

Prerequisites

Installation and Setup

  1. Install and Run MySQL:

    • Follow the instructions for your operating system to install and start the MySQL server.
  2. Choose MySQL User:

    • Use Root User: If you prefer to use the root user, you can skip steps 2.1 and 2.2. However, using a dedicated user with limited privileges is generally recommended for security reasons.

    • Create a New User: To create a separate user with appropriate permissions, proceed with the following steps:

      • Access the MySQL console:
        mysql -u root -p
      • Create a user (replace username and password with your desired credentials):
        CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
      • Grant necessary permissions to the user:
        GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost';  # Grant all privileges for simplicity, but consider granting only specific privileges for better security
  3. Create Database and Table:

    • Create the database:
      CREATE DATABASE Inventory;
    • Switch to the database:
      USE Inventory;
    • Create the table:
      CREATE TABLE products (
          id int NOT NULL AUTO_INCREMENT,
          name varchar(255) NOT NULL,
          quantity int,
          price float(10,7),
          PRIMARY KEY(id)
      );
  4. Store Password :

    • Store the MySQL password securely in your environment:
      echo "export DB_PASSWORD=Your_Password" >> ~/.zshrc  # For Z shell
      export DB_PASSWORD=Your_Password  # For current session

Building and Running the Project

  1. Build the Project:
    go build
    
  2. Run the executable:
    ./file_name

go-crud-api-project's People

Contributors

gjs2162 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.