Skip to content

Fikri1234/CRUD_REST_MUX_MySQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST-Golang-MUX-MySQL

Web service CRUD using Golang with gorilla-MUX for create REST api, MySQL as database, Viper as environment variable and sqlmock assert for Testing.

Prerequisites

  1. Go
  2. Gorilla Mux
  3. Mysql
  4. Viper
  5. SQLMock
  6. Assert

Getting Started

  1. Firstly, we need to get MUX, MySQL, Viper, sqlmock, assert library dependencies and install it
go get github.com/gorilla/mux  
go get github.com/go-sql-driver/mysql
go get github.com/spf13/viper
go get github.com/DATA-DOG/go-sqlmock
go get github.com/stretchr/testify/assert
  1. Import dump.sql to your MySQL and configure your credential in folder resource Alt text

  2. Open cmd in your project directory and type go test -v , you should get a response similar to the following: Alt text

  3. To run application,open cmd in your project directory and type

go run main.go

Sample Payload

  1. Get User By Id
  2. Get User Detail By Id
  3. Get All User
  4. Get All User Detail
  5. Create User
  6. Create User Detail
  7. Update User
  8. Update User Detail
  9. Delete User By Id
  10. Delete User Detail By Id
  11. Example error response,in case Update User Detail

About

REST CRUD Golang with gorilla-MUX and MySQL

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages