Skip to content

Implementation of clean architecture in go for web service

License

Notifications You must be signed in to change notification settings

dean2032/go-project-layout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go project layout

This is a simple clean architecture template with gin framework, fx as dependency container, gorm as orm for database related operations.

Implemented Features

  • Dependency Injection (go-fx)
  • Routing (gin web framework)
  • Logging provides context trace(trace_id) and log file rotation (zap and lumberjack)
  • Gin middlewares setup (cors, zap logger with custom log format)
  • Database Setup (mysql)
  • Models Setup and Automigrate (gorm with zap logger)
  • Authentication (JWT)
  • Migration Runner Implementation
  • Cobra Commander CLI Support. try: go run . --help
  • Pprof setup with gin

Running the project

  • Make sure you have go and git installed.
  • Clone and build app:
    $ go clone https://github.com/dean2032/go-project-layout.git
    $ cd go-project-layout
    $ go build -o app
  • Run a subcommand of app. Two subcommands are provided:
    • file_server: this subcommand will run a file download web server exposing the current directory on port 8888:
      $ ./app file_server -verbose
    • api_server: this subcommand will run a http api server. Mysql db must be installed and configured correctly before it can run properly. See ./deployments/migration for more details.

Have fun!

About

Implementation of clean architecture in go for web service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages