Go lib
Shared Go library for the A-Novel backend services — the glue they'd otherwise copy between repos.



What this is
Not a framework, and small on purpose: if a well-maintained library already covers it, it doesn't live here. A sub-package that grows a broad API of its own graduates to its own repo, as jwt did.
Full reference: godoc on pkg.go.dev.
Installation
go get github.com/a-novel-kit/golib
Sub-packages
Each sub-package is a directory-scoped, independently importable helper — focused, dependency-light, and shared across services. One that grows a broad API of its own graduates to its own repo (see What this is).
| Path |
What it's for |
config |
Loads environment variables into typed config structs and fails fast at startup when one is missing or malformed, so a service never boots half-configured. |
otel |
Wires OpenTelemetry tracing and logging under a shared app identity and reports each operation's outcome on its span. Exporters ship for local development and Google Cloud. |
httpf |
Holds the REST boundary logic a handler leans on — mapping domain error sentinels to HTTP status codes and writing JSON — so every service answers errors the same way. |
grpcf |
The gRPC equivalent of httpf: it shapes per-call context, supplies client and server credentials (local or GCP), and bundles a health/echo service for tests. |
logging |
Defines the interfaces the platform logs through, so a service can swap its log backend without touching call sites. Presets cover local and Google Cloud, for both HTTP and gRPC. |
postgres |
Carries the database handle on the request context and scopes work into transactions, and ships a migration runner plus harnesses that give each test an isolated database. |
smtp |
Sends transactional mail behind one Sender interface, with a real SMTP sender for production and a debug sender for local runs and tests. |
Contributing
Setup and day-to-day commands are in the developer onboarding guide; golib-specific notes are in CONTRIBUTING.md.