servette is a lightweight Go backend toolkit for building web services with less boilerplate. It collects common helpers for application lifecycle management, configuration loading, environment access, structured logging, HTTP transport, JSON encoding, JWT handling, password hashing, localization, and reusable service clients.
The package is designed to help you wire together the repetitive parts of a Go service without forcing a large framework on top of your codebase. The main idea is to keep the building blocks small, composable, and ready to use.
- application lifecycle orchestration with
app - environment-driven configuration with
configandconfig/env - password hashing with
crypto - JWT token generation, validation, and cookie helpers with
auth/jwt - OAuth client helpers with
auth/oauth - JSON helpers for HTTP handlers and typed decoding with
encoding/json - structured logging helpers with
logger - URL and project-path helpers with
path - toast notifications through HTTP headers with
toast - translation bundles and language resolution with
translation - transport and HTTP protocol helpers with
transport - ready-to-use external service clients under
domain
app— application lifecycle runner abstractionauth— authentication helpers such as JWT and OAuthconfig— configuration loading and compositioncrypto— password hashing and verificationdomain— ready-to-use service clients for external systemsencoding/json— JSON encode/decode helpersenv— environment variable loading and parsinglogger— structured logging helperspath— project root and path utilitiestoast— server-triggered toast notificationstranslation— bundles, resolvers, and i18n helperstransport— HTTP transport and protocol helpers
The app package provides a small runner abstraction for coordinating long-running components. It is built around a Runner interface with Start and Shutdown methods, so you can run servers, workers, or any other background processes through one entry point.
These packages load application configuration from environment variables. They are designed around prefix-based configuration so the same app can be deployed in multiple environments or instances without changing code.
The env package wraps common environment-variable tasks such as loading .env files, reading values, and parsing booleans, integers, and durations.
Authentication helpers are split into focused packages:
jwtfor token creation, validation, and cookie managementoauthfor OAuth2 authorization flows and provider profile fetching
The crypto package provides bcrypt password hashing and password verification helpers.
This package adds convenience wrappers around Go’s standard JSON support, including HTTP response helpers and generic decode functions.
The logger package wraps log/slog with environment-aware initialization and helper functions for function-call logging with request IDs and optional timing.
Path utilities help with discovering the project root and building URL-style paths.
The toast package sends JSON payloads through the HX-Trigger header so the frontend can show success, error, info, or warning toasts.
The translation packages load language bundles from JSON files, resolve the active language, and return translated strings with a simple T(key) lookup.
Transport helpers define HTTP-oriented request/response conventions and protocol-level utilities for passing data through handlers.
The domain tree contains preconfigured clients for external systems such as databases, caches, and other integrations.
appRunner := app.New(logger, httpServer, backgroundWorker)
if err := appRunner.Run(ctx); err != nil {
logger.Error("app stopped", "err", err)
}cfg, err := appenv.LoadConfig("WEB")
if err != nil {
return err
}
log := logger.New(cfg.Mode)hash, err := crypto.HashPassword("my-secret-password")
if err != nil {
return err
}toast.Success(w, "Saved successfully")- Go
1.25.4
go get github.com/Deirror/servetteservette aims to remove repetitive setup code while staying close to standard Go patterns. Each package is intentionally small, focused, and easy to compose with the rest of your codebase.
Contributions are welcome. Please open an issue or pull request.
MIT