Go Api Boilerplate

screenshot of Go Api Boilerplate

Boilerplate for Golang API

Overview

The Go API Boilerplate is a framework for building APIs in Go. It provides a variety of features and tools to facilitate the development process, including a web framework (Gin), a package manager (go mod), dependency injection based on a service container, layered architectural pattern, API routing, request/response conversion to JSON/XML, logging capabilities (logrus), environment variables and config management (Viper), ORM (GORM) for database operations, database migrations (gorm-goose), base CRUD services, repositories, and controllers, request validation using Gin, console commands (Cobra), unit tests with service overriding, code coverage analysis, integrations with Sentry for logging errors, alerting for unhandled errors, and Swagger documentation generation.

Features

  • Framework for API: Gin
  • Package manager: go mod
  • Dependency Injection based on service container
  • Layered architecture: Controller->Service->Repository->Entity
  • API routing using Gin
  • Request/response conversion to JSON/XML based on request headers
  • Logging with logrus
  • Environment variables and config management using Viper
  • ORM for database operations: GORM
  • Database migrations with gorm-goose
  • Base CRUD service, repository, and controller
  • Request validation using Gin
  • Console commands with Cobra
  • Unit tests with service overriding (go test)
  • Code coverage analysis (go tool cover)
  • Integration with Sentry for logging (logrus_sentry)
  • Alerting for unhandled errors
  • Swagger documentation

Summary

The Go API Boilerplate provides a comprehensive set of tools and features for building APIs in Go. It includes a powerful web framework, dependency injection, layered architecture, database operations with ORM and migrations, request validation, logging with Sentry integration, and Swagger documentation generation. With its easy installation process, developers can quickly set up their environment and start building robust APIs in Go.