Skip to content

jeremychow99/Govtech-Go-Assessment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GovTech Internship Assessment (GDS-OCV)

REST API built using Golang, Gin and GORM with MySQL.

Installation & Setup

Requirements: Golang installed, and a MySQL database to connect to.

  1. Create a database/schema in MySQL.
  2. In the .env file as shown below, modify the DB_URL accordingly based on your MySQL Credentials and name of schema/db you just created. Can also change PORT if required.
    PORT=3000
    DB_URL=user:pass@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local
    
  3. For example, I used a MySQL schema with dbname: test123, user: root, pass: root, so my DB_URL was root:root@tcp(127.0.0.1:3306)/test123?charset=utf8mb4&parseTime=True&loc=Local.
  4. In folder root, run go run main.go to auto download dependencies.
  5. In folder root, open another terminal/CLI instance, run go run migrate/migrate.go to create database tables.
  6. API ready to be used.

Some Notes

main_test.go which contains the unit tests does not work. Need to learn how to do proper unit tests for GORM (maybe using SqlMock?).

About

REST API built using Go, Gin and GORM with MySQL.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published