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.
contractCore interfaces (ports): ORM, Database, Rows, Row, Tx, Transactional, Cache, Storage, Token, Claims.
configLoad .env files into typed Config structs. Validates JWT_SECRET on load. Builds Postgres DSN automatically.
adapter/gormdefaultGORM v2 PostgreSQL adapter. Implements contract.ORM. Default database adapter for all generated modules.
adapter/postgresRaw SQL adapter. pgx v5 connection pool. Implements contract.Database and contract.Transactional.
adapter/redisgo-redis v9 client. Implements contract.Cache. Values serialized with json.Marshal for consistency with mock.
adapter/minioMinIO object storage. Auto-creates buckets on startup. Presigned URLs with caller-controlled expiry.
adapter/jwtgolang-jwt v5, HMAC-SHA256. Sets iat+exp claims. Validates signing method to prevent alg:none attacks.
middlewareFiber middleware: JWT auth, RBAC role checking, configurable CORS with preflight support.
errsAppError type with HTTP status + error code. Sentinels: NotFound, BadRequest, Unauthorized, Conflict, etc.
responseStandard JSON response envelope: Success, SuccessMessage, Paginated, Error. Consistent API responses.
i18nThread-safe locale registry. Parse Accept-Language header. Built-in EN, LO (Lao), TH, ZH. Custom locales.
validatorStruct validation via go-playground/validator. Human-readable field error messages. Custom rule registration.
hashbcrypt password hashing and verification via golang.org/x/crypto.
paginateOffset pagination params. Normalize() clamps Page/Limit. Offset() computes DB offset without mutation.
loggerslog-based logger factory. Development() for text output, Production() for JSON. Zero external deps.
mockFunction-override test doubles for Database, Cache, Storage, Token, Tx, TransactionalDB. No mock frameworks.