go-sample
Go Backend Sample. It’s suitable as a starting point for a REST-API Go application.
This example uses:
Features:
- Modular Project Structure.
- Built-in migration handling.
- Ready to go example with tests and mocks.
- Easy-to-go Docker deployment.
Structure
go-sample
├── cmd
│ └── cli // Entry point for the application.
├── commands // Sub-commands for CLI (stands for Command Line Interface).
│ ├── migrate.go // Migration sub-command. It creates, applies, and rollbacks DB-migrations.
│ └── server.go // Server sub-command. It runs the HTTP server.
├── internal // Internal packages for the application according to Go convention.
│ ├── business // Business logic of the application.
│ │ └── snippets // A specimen business-logic package “snippets” with REST-API for snippets creating, listing, and deleting.
│ └── infrastructure // Infrastructure code of the application.
│ ├── api // API-related utilities: middlewares, authentication, error handling for the transport layer.
│ ├── log // Convenient logger to decouple from the standard log package.
│ └── service // Service-related reusable code: error handling for the service layer, etc.
└── migrate // Reusable migration utilities.
└── migratorions // This folder contains *.sql migrations.
Installation
git clone https://github.com/titusjaka/go-sample
Usage
docker-compose up --build
Future improvements