lib

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT

README

lib

Shared Go libraries for AltSoyuz projects. Single Go module (github.com/AltSoyuz/lib), one importable package per top-level directory.

These packages were extracted from the homeapp SaaS template so that other apps (shadcnsvelte, exploreassistant, …) can consume them via standard go get instead of a replace directive.

Philosophy

Inspired by VictoriaMetrics' approach to library code:

  • Minimal external dependencies. Adding a dep requires justification.
  • Stable APIs. Breaking changes bump the minor version (pre-1.0) or require a /v2 module path (post-1.0). No silent breakage.
  • Tests are mandatory. Every package ships with *_test.go. CI runs go test -race ./... and go vet ./... on every push/PR.
  • No frameworks, no magic. Plain net/http, plain database/sql, log/slog. Composition over inheritance.
  • Read the code. Each package fits in your head. Read the source before reaching for docs.

Packages

Package Purpose
auth Authentication primitives: passwords (bcrypt + HIBP), sessions, magic links. App composes its own DB + handlers.
buildinfo Build version / commit injection via -ldflags.
claude Anthropic Claude API client.
db database/sql helpers: migrations, query tracing, transactions.
envflag flag package wrapper that also reads from environment variables.
httpserver HTTP server utilities: graceful shutdown, IP extraction, rate limiting, embedded UI helpers.
logger log/slog configuration with sane defaults.
mailer Email sender (AWS SES v2).
oauthgoogle Google OAuth2 client.
telegram Telegram bot API client.

Install

go get github.com/AltSoyuz/lib@latest

Then import the packages you need:

import (
    "github.com/AltSoyuz/lib/httpserver"
    "github.com/AltSoyuz/lib/logger"
)

Versioning

Standard Go module semver. Tags are vMAJOR.MINOR.PATCH. While the module is v0.x.y the API may change between minor versions; breaking changes will be called out in CHANGELOG.md.

Contributing

See CONTRIBUTING.md.

License

MIT

Directories

Path Synopsis
auth
magiclinks
Package magiclinks holds shared semantics for one-shot email tokens used by the verify-email and password-reset flows: TTL defaults and stable purpose strings used as DB enums.
Package magiclinks holds shared semantics for one-shot email tokens used by the verify-email and password-reset flows: TTL defaults and stable purpose strings used as DB enums.
passwords
Package passwords provides bcrypt password hashing, email normalization, and breach-check via the HaveIBeenPwned k-anonymity API.
Package passwords provides bcrypt password hashing, email normalization, and breach-check via the HaveIBeenPwned k-anonymity API.
sessions
Package sessions provides session token generation, cookie helpers, and request URL/host detection.
Package sessions provides session token generation, cookie helpers, and request URL/host detection.

Jump to

Keyboard shortcuts

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