Getting Started

Introduction

bkgo is a production-ready Go backend foundation package built on Hexagonal Architecture. It provides adapters, contracts, middleware, CLI scaffolding, and i18n — so every Go backend project starts with a solid, consistent foundation.


Why bkgo?

Go projects tend to reinvent the same boilerplate — database connection pooling, JWT middleware, error types, response envelopes, pagination — in every new service. bkgo solves that once, following Hexagonal Architecture so your business logic never depends on a concrete adapter.

  • Contracts define what your system needs — adapters deliver it.
  • Swap PostgreSQL, Redis, or MinIO without touching domain code.
  • Generated modules are test-ready with mock test doubles included.
  • i18n baked in — error messages auto-translate from Accept-Language header.
  • CLI scaffolds full projects and individual modules instantly.

Architecture Overview

Your Project
    │
    ├── internal/user/
    │   ├── domain.go        ← entity + Repository interface  (PORT)
    │   ├── usecase.go       ← business logic (depends on PORT only)
    │   ├── handler.go       ← HTTP delivery (Fiber)
    │   └── repository.go    ← PostgreSQL implementation      (ADAPTER)
    │
    └── cmd/api/main.go      ← wire everything together
            │
            ├── bkgo/adapter/postgres  ← satisfies contract.Database
            ├── bkgo/adapter/redis     ← satisfies contract.Cache
            ├── bkgo/adapter/minio     ← satisfies contract.Storage
            └── bkgo/adapter/jwt       ← satisfies contract.Token

Quick Install

Install the package:

$go get github.com/BounkhongDev/bkgo

Install the CLI:

$go install github.com/BounkhongDev/bkgo/cmd/bkgo@latest