Skip to content

Golang RESTAPI with postgresql using gin and pgx driver

License

Notifications You must be signed in to change notification settings

reshimahendra/lbw-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LBW-GO, GIN Restful-api Project starter

Golang restful-api project starter-kit with Gin and Postgresql (using pgx library). This starter project build using DDD model architect.

# NOTE: PROJECT is NOT READY yet.

Table of Content

  1. Quick Review
  2. Directory Structure
  3. Getting started
  4. TODO

1. Quick Review

The package used in this project:

  • Gin, most stared Go web framework on Github
  • pgx, the best PostgreSQL driver for Go
  • jwt, Jwt Authentication and Authorization
  • logrus, logger for access log, database log, and server log
  • viper, complete configuration solution
  • Air, Hot reload support for fast development

2. Directory Structure

|-- root/
|-- |-- cmd/
|-- |-- |-- app/
|-- |-- |-- |-- server/
|-- |-- |-- main.go
|-- |-- config/
|-- |-- |-- .config.yaml
|-- |-- dist/
|-- |-- internal/
|-- |-- |-- app/
|-- |-- |-- |-- account/
|-- |-- |-- |-- |-- datastore/
|-- |-- |-- |-- |-- handler/
|-- |-- |-- |-- |-- service/
|-- |-- |-- |-- |-- README.md
|-- |-- |-- |-- |-- router.go
|-- |-- |-- |-- mail/
|-- |-- |-- config/
|-- |-- |-- database/
|-- |-- |-- |-- sql/
|-- |-- |-- domain/
|-- |-- |-- pkg/
|-- |-- |-- |-- auth/
|-- |-- |-- |-- errors/
|-- |-- |-- |-- helper/
|-- |-- |-- |-- logger/
|-- |-- log/
|-- |-- vendor/
|-- |-- go.mod
|-- |-- go.sum
|-- |-- LICENSE
|-- |-- Makefile
|-- |-- README.md

3. Getting Started

copy config file

Before we run the app, make sure the config has been set. from the root directory, run

cp config/example.config.yaml .config.yaml

run app

to test application (with hot reload), run:

air

OR

run without hot reload:

make run

build app

To build the app, run:

make build

run test

To run the test, run:

make test

Show test coverage result on browser:

# make sure file 'proof.out already exist/ generated'
make show-test

Generate new test coverage and show result on browser:

make test-proof

4. TODO

  • Jwt Authentication and Authorization
  • Add Test
  • Add blog app

About

Golang RESTAPI with postgresql using gin and pgx driver

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published