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
$ docker-compose build --no-cache
$ 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

👮 License
MIT