go-boilerplate

command module
v0.0.0-...-a255732 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: MIT Imports: 11 Imported by: 0

README

Golang API Server Boilerplate (Work In Progress)

A boilerplate/starter project for quickly building APIs using Golang with Clean Architechture

🎨 Features

  • Web Framework: Switchable between Mux, Gin.
  • Logging: Switchable between Zap or plain logging.
  • SQL database: Using GORM for ORM library. (will be added more later...)
  • Testing: Use Testify for testing framework.
  • Docker support:
    • Using multi-stage build to reduce production image size
    • Using nodemon to do live-reload when development

🐳 How to run using Docker

  • Start production enviroment
$ docker-compose up -d production
// View logs
$ docker-compose logs --tail 100 -f production
  • Start development enviroment
$ docker-compose up development
  • Re-building docker
$ docker-compose build --no-cache
  • Attach to bash
$ docker-compose exec <production|development> sh

🌲 Project Folder Structure

+-- app
|  +-- controller
|  +-- entity
|  +-- error
|  +-- infrastructure
|  |   +-- gorm
|  |   |   +-- database
|  |   |   +-- repository
|  |   +-- http
|  |   +-- logging
|  +-- usecase
+-- docker

❓ How to

  • Build docker image with cutom tag: docker build -t go-boilerplate .
  • Build docker image with custom Dockerfile: docker build -f ./docker/Dockerfile .
  • Remove none:none image: docker rmi $(docker images -f "dangling=true" -q)
  • Run docker: docker run -p 8000:8000 go-boilerplate
  • Sync local branch with remote: git fetch -p
  • Ignoring files that are already tracked: git update-index —assume-unchanged <file>
  • To get undo/show dir's/files that are set to assume-unchanged run this: git update-index --no-assume-unchanged <file>
  • To get a list of dir's/files that are assume-unchanged run this: git ls-files -v|grep '^h'
  • Auto reload using nodemon: nodemon --exec go run main.go --signal SIGTERM

💡 Reference

Clean Architechture Image

👮 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