Giter Site home page Giter Site logo

ramanaptr / golang-crud-rest-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iammukeshm/golang-crud-rest-api

0.0 0.0 0.0 6.47 MB

Implementing CRUD in Golang REST API with Mux & GORM

Home Page: https://codewithmukesh.com/blog/implementing-crud-in-golang-rest-api/

Go 100.00%

golang-crud-rest-api's Introduction

Implementing CRUD in GoLang REST API with Echo & GORM

CRUD in GoLang REST API with Mux & GORM

In this article, we will learn about implementing CRUD in Golang REST API with Echo for routing requests, GORM as the ORM to access the database, Viper for Loading configurations, and PostgreSQL as the database provider. We will also follow some clean development practices to help organize the GoLang project folder structure in a more easy-to-understand fashion.

Topics Covered

  • Setting up the Golang Project
  • Loading Configurations using Viper
  • Defining the Product Entity
  • Connecting to the database
  • Routing
  • Implementing CRUD in Golang Rest API
    • Create
    • Get By ID
    • Get All
    • Update
    • Delete
  • Testing CRUD Operations

Read the entire article here - https://codewithmukesh.com/blog/implementing-crud-in-golang-rest-api/

Config your own Golang

  • Create your own database on PostgreSQL Server
  • Rename config.json.example to config.json
  • Change the value of 'connection_string' in the config file:
{
  "connection_string": "user=username password=yourpassword dbname=yourdb host=localhost port=5432 sslmode=disable TimeZone=Asia/Singapore",
  "domain": "http://localhost",
  "port": 8080
}

Up to date the dependencies version (Recommended)

go get -u

Or only download current dependencies version (Not Recommended)

go get

Run on local/dev mode

go run .

Build

go build -o file_name

Run Build at Terminal

./file_name

Test Rest API

Install plugin on vscode named: REST Client or others like 'ext:rest'
Test the rest API at folder:

~/golang-crud-rest-api/collection/products.rest

golang-crud-rest-api's People

Contributors

iammukeshm avatar ramanaptr 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.