Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/agieaja/crudgolang

Sample API CRUD Golang And Gin
https://github.com/agieaja/crudgolang

api crud gin golang sample

Last synced: about 3 hours ago
JSON representation

Sample API CRUD Golang And Gin

Awesome Lists containing this project

README

        

Sample API CRUD using Golang And Gin

Instalation





  1. Create some database and Import table in the folder database on MYSQL


  2. Open your terminal and run command :

    • go get github.com/gin-contrib/logger

    • go get github.com/gin-gonic/gin

    • go get github.com/rs/zerolog

    • go get github.com/rs/zerolog/log

    • go get github.com/jinzhu/gorm

    • go get github.com/go-sql-driver/mysql




  3. Change the contents of the connectdb.go file in the config folder as follow :

    • dbHost := "your host name / IP database"

    • dbPort := "your port hostname / IP database"

    • dbUser := "your user database"

    • dbPass := "your password database"

    • dbName := "your database name"



  4. Open your terminal on the root project and run command go run main.go

Module




Module
Method
URL
Description
Request Body


Add
POST
{baseURL}/phonebook/add
Add some data in table phone_books
{"name":"Tiar","phone":"12346"}


Edit
POST
{baseURL}/phonebook/edit
edit some data in table phone_books
{"id":1,"name":"Tiar","phone":"12346"}


List
GET
{baseURL}/phonebook/list
get all data in table phone_books
-


Get Data by ID
GET
{baseURL}/phonebook/data/id
get data by id in table phone_books
-


Delete
POST
{baseURL}/phonebook/delete
delete some data in table phone_books
{"id":1}