Coder Social home page Coder Social logo

goshopmvc's Introduction

Product CRUD Application in Golang

Overview

This is a simple CRUD (Create, Read, Update, Delete) application written in Golang, following the MVC (Model-View-Controller) architecture. The application allows you to manage products, providing basic functionalities to create, retrieve, update, and delete product information.

Features

  • Create: Add new products with details such as name, description, and price.
  • Read: Retrieve a list of all products or get details of a specific product.
  • Update: Modify product information, including name, description, and price.
  • Delete: Remove products from the system.

Technologies Used

  • Golang: The primary programming language.
  • pq: Pure Go Postgres driver for database/sql.
  • Postgres: The open-source relational database management system.
  • Docker: A platform for developing, shipping, and running applications using containerization.

Project Structure

The project structure consists of the following directories and files:

├── controllers
│   └── produtos.go
├── db
│   └── db.go
├── docker-compose.yml
├── go.mod
├── go.sum
├── main.go
├── models
│   └── produtos.go
├── README.md
├── routes
│   └── routes.go
└── templates
    ├── edit.html
    ├── _head.html
    ├── index.html
    ├── _menu.html
    └── new.html

5 directories, 14 files
  • controllers: This folder contains the controller files for handling different aspects of the application's logic. In this case, it includes a produtos.go file, which likely contains the controller logic for managing products.

  • db: This folder contains the database-related files. The db.go file is likely responsible for establishing a connection to the database and providing functions for interacting with it.

  • models: This folder contains the model files that define the structure and behavior of the application's data. In this case, it includes a produtos.go file, which likely defines the product model.

  • routes: This folder contains the route files that define the API endpoints and their corresponding handlers. In this case, it includes a routes.go file, which likely defines the routes for managing products.

  • templates: This folder contains the HTML templates used for rendering the views of the application. It includes various HTML files such as edit.html, index.html, new.html, etc., which define the structure and content of different pages.

The project structure is organized in a way that separates concerns and promotes modularity. This allows for easier maintenance and scalability of the application.

Getting Started

  1. Ensure you have Golang installed on your machine.
  2. Clone this repository: git clone https://github.com/helioLJ/GoShopMVC.git
  3. Change into the project directory: cd GoShopMVC
  4. Run the application: go run main.go

API Endpoints

  • GET /: This endpoint displays the index page of the application.
  • GET /new: This endpoint displays the page for creating a new item.
  • POST /insert: This endpoint is used to insert a new item into the database.
  • POST /delete: This endpoint is used to delete an existing item from the database.
  • GET /edit: This endpoint displays the page for editing an existing item.
  • POST /update: This endpoint is used to update an existing item in the database.

Dependencies

  • pq: Pure Go Postgres driver for database/sql.

Contributing

Feel free to contribute by submitting issues or pull requests. Your feedback and collaboration are welcome!

goshopmvc's People

Contributors

heliolj 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.