golib

package module
v0.30.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 0 Imported by: 0

README

Go lib

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

X (formerly Twitter) Follow Discord


GitHub go.mod Go version GitHub repo file or directory count GitHub code size in bytes

GitHub Actions Workflow Status

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 hosted backends.
httpf Both sides of the HTTP wire: mapping domain error sentinels to status codes and writing JSON responses, and the pooled, traced client a service calls other systems through. httpftest scripts a server to test those calls against.
grpcf The gRPC equivalent of httpf: it shapes per-call context, supplies client dial 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 runs work inside transactions installed on it, 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.
transaction Declares what a unit of work is, in one interface that names no database — so business code can require atomicity without gaining a way to reach a driver. postgres implements it.
worker Runs the loops that live beside the request path: an error keeps the loop alive, a busy tick skips the wait, and loops sharing an interval de-synchronize.

Contributing

Setup and day-to-day commands are in the developer onboarding guide; golib-specific notes are in CONTRIBUTING.md.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package config reads service configuration from environment variables, mapping raw strings to native Go types through composable parser functions.
Package config reads service configuration from environment variables, mapping raw strings to native Go types through composable parser functions.
Package httpf holds the HTTP glue a service needs on both sides of the wire.
Package httpf holds the HTTP glue a service needs on both sides of the wire.
httpftest
Package httpftest scripts an HTTP server for testing outbound calls.
Package httpftest scripts an HTTP server for testing outbound calls.
Package logging defines the logging contracts a service wires into its HTTP and gRPC servers.
Package logging defines the logging contracts a service wires into its HTTP and gRPC servers.
presets
Package loggingpresets provides ready-made implementations of the logging package interfaces for the two environments a service runs in: Google Cloud and local development.
Package loggingpresets provides ready-made implementations of the logging package interfaces for the two environments a service runs in: Google Cloud and local development.
Package smtp sends templated transactional email through a pluggable Sender.
Package smtp sends templated transactional email through a pluggable Sender.
smtptest
Package smtptest provides an in-memory smtp.Sender for unit and integration tests.
Package smtptest provides an in-memory smtp.Sender for unit and integration tests.
Package transaction declares the scope a unit of work runs in, independently of what stores it.
Package transaction declares the scope a unit of work runs in, independently of what stores it.
transactiontest
Package transactiontest provides an in-memory [transaction.Transactor] for unit tests.
Package transactiontest provides an in-memory [transaction.Transactor] for unit tests.
Package worker holds the loops a service runs in the background, beside the request path.
Package worker holds the loops a service runs in the background, beside the request path.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL