simple-go-clean-arch

command module
v0.0.0-...-5c56469 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2020 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Build Status codecov Go Report Card

SIMPLE-GO-CLEAN-ARCH

Simple Go Clean Arch Using Golang (Gin Gonic Framework) as Programming Language, MariaDB as Database

Directory structure

Your project directory structure should look like this

  + your_gopath/
  |
  +--+ src/github.com/moemoe89
  |  |
  |  +--+ simple-go-clean-arch/
  |     |
  |     +--+ main.go
  |        + api/
  |        + routers/
  |        + ... any other source code
  |
  +--+ bin/
  |  |
  |  +-- ... executable file
  |
  +--+ pkg/
     |
     +-- ... all dependency_library required

Setup and Build

$ mkdir -p src/github.com/moemoe89
$ cd src/github.com/moemoe89
$ git clone <url>
$ mv <cloned directory> simple-go-clean-arch

Running Migration

  • Copy config-sample.json to config.json and changes the value based on your configurations.
  • Create MySQL database for example named simple_api and do migration with Goose https://bitbucket.org/liamstask/goose/
  • Change database configuration on dbconf.yml like dialect and dsn for each environtment
  • Do the following command
$ cd $GOPATH/src/github.com/moemoe89/simple-go-clean-arch
$ goose -env=development up

Documetation with Swagger

For open swagger access via browser

{{url}}/swagger/index.html

For updating swagger

$ swag init

Running Application with Makefile

Make config file for local :

$ cp config-sample.json config-local.json

Build

$ cd $GOPATH/src/github.com/moemoe89/simple-go-clean-arch
$ make build

Run

$ cd $GOPATH/src/github.com/moemoe89/simple-go-clean-arch
$ make run

Stop

$ cd $GOPATH/src/github.com/moemoe89/simple-go-clean-arch
$ make stop

Make config file for docker :

$ cp config-sample.json config-docker.json

Docker Build

$ cd $GOPATH/src/github.com/moemoe89/simple-go-clean-arch
$ make docker-build

Docker Up

$ cd $GOPATH/src/github.com/moemoe89/simple-go-clean-arch
$ make docker-up

Docker Down

$ cd $GOPATH/src/github.com/moemoe89/simple-go-clean-arch
$ make docker-down

How to Run with Docker

Make config file for docker :

$ cp config-sample.json config.json

Build

$ docker-compose build

Run

$ docker-compose up

Stop

$ docker-compose down

How to Run Unit Test

Run

$ go test ./...

Run with cover

$ go test ./... -cover

Run with HTML output

$ go test ./... -coverprofile=c.out && go tool cover -html=c.out

Reference

Thanks to this medium link for sharing the great article

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址