Packages

Package Overview

bkgo ships 16 independent packages. Import only what you need — every package has no dependency on the others except through the contract interfaces.


contract
portsinterfaces

Core interfaces (ports): ORM, Database, Rows, Row, Tx, Transactional, Cache, Storage, Token, Claims.

config
envvalidation

Load .env files into typed Config structs. Validates JWT_SECRET on load. Builds Postgres DSN automatically.

adapter/gormdefault
gormpostgres

GORM v2 PostgreSQL adapter. Implements contract.ORM. Default database adapter for all generated modules.

adapter/postgres
postgrespgx

Raw SQL adapter. pgx v5 connection pool. Implements contract.Database and contract.Transactional.

adapter/redis
rediscache

go-redis v9 client. Implements contract.Cache. Values serialized with json.Marshal for consistency with mock.

adapter/minio
miniostorage

MinIO object storage. Auto-creates buckets on startup. Presigned URLs with caller-controlled expiry.

adapter/jwt
jwtauth

golang-jwt v5, HMAC-SHA256. Sets iat+exp claims. Validates signing method to prevent alg:none attacks.

middleware
fiberauthrbac

Fiber middleware: JWT auth, RBAC role checking, configurable CORS with preflight support.

errs
errorshttp

AppError type with HTTP status + error code. Sentinels: NotFound, BadRequest, Unauthorized, Conflict, etc.

response
jsonapi

Standard JSON response envelope: Success, SuccessMessage, Paginated, Error. Consistent API responses.

i18n
i18nlocalization

Thread-safe locale registry. Parse Accept-Language header. Built-in EN, LO (Lao), TH, ZH. Custom locales.

validator
validationinput

Struct validation via go-playground/validator. Human-readable field error messages. Custom rule registration.

hash
bcryptsecurity

bcrypt password hashing and verification via golang.org/x/crypto.

paginate
pagination

Offset pagination params. Normalize() clamps Page/Limit. Offset() computes DB offset without mutation.

logger
sloglogging

slog-based logger factory. Development() for text output, Production() for JSON. Zero external deps.

mock
testingmocks

Function-override test doubles for Database, Cache, Storage, Token, Tx, TransactionalDB. No mock frameworks.