Skip to main content

What is Salt?

Salt is a Golang utility library that provides a collection of modular, reusable packages designed to simplify and enhance application development. It offers battle-tested components for common tasks, including configuration management, CLI utilities, authentication, logging, database operations, and observability. Built and maintained by Raystack, Salt powers production applications across the Raystack ecosystem.

Why use Salt?

Salt eliminates the need to write boilerplate code for common application needs, allowing you to focus on building your core business logic.

Production-ready

Battle-tested libraries used in production across the Raystack ecosystem

Modular design

Import only what you need without unnecessary dependencies

Type-safe

Full Go type safety with comprehensive validation support

Cloud-native

Built for modern infrastructure with observability and graceful shutdowns

Key features

Configuration management

Load and validate configuration from multiple sources with a clear precedence order:
loader := config.NewLoader(
    config.WithFile("./config.yaml"),
    config.WithEnvPrefix("MYAPP"),
    config.WithFlags(flags),
)
Configuration sources are merged with the following precedence (highest to lowest):
  1. Command-line flags
  2. Environment variables
  3. Configuration files
  4. Default values

Structured logging

Choose between Logrus and Zap implementations with a unified interface:
// Using Logrus
logger := log.NewLogrus(
    log.LogrusWithLevel("info"),
)

// Using Zap
logger := log.NewZap(
    log.ZapWithConfig(zapConfig),
)

logger.Info("request processed", "duration", duration, "status", 200)

Database operations

Connect to databases with connection pooling, timeouts, and transaction support:
client, err := db.New(db.Config{
    Driver:          "postgres",
    URL:            "postgres://user:pass@localhost/db",
    MaxOpenConns:   25,
    MaxIdleConns:   5,
    ConnMaxLifeTime: 5 * time.Minute,
})

CLI utilities

Build interactive command-line tools with:
  • Commander: Command management and documentation generation
  • Printer: Formatted output (tables, JSON, YAML, markdown)
  • Prompter: Interactive user prompts and surveys
  • Terminator: Terminal utilities and browser integration

Authentication & security

  • OIDC: OpenID Connect authentication flows and token management
  • Audit: Security event logging and compliance tracking

Observability

Integrate OpenTelemetry for metrics, traces, and monitoring:
cleanup, err := telemetry.Init(ctx, telemetry.Config{
    AppName:    "my-service",
    AppVersion: "1.0.0",
}, logger)
defer cleanup()

Package overview

config

Configuration management with environment variables, files, and defaults

log

Structured logging with Logrus and Zap support

db

Database connections, migrations, and transaction helpers

cli

Command-line tools, prompts, and formatted output

auth

OIDC authentication and audit logging

server

HTTP server utilities and SPA serving

telemetry

OpenTelemetry integration for observability

jsondiff

JSON diff calculation and reconstruction

Who uses Salt?

Salt is used across the Raystack ecosystem to power production applications including:
  • API services and microservices
  • CLI tools and utilities
  • Data processing pipelines
  • Infrastructure management tools

Requirements

  • Go 1.22 or higher
  • Compatible with Linux, macOS, and Windows

Next steps

1

Install Salt

Get started by installing Salt in your Go projectInstallation guide →
2

Quick start

Build your first application with SaltQuickstart guide →
3

Explore packages

Dive deeper into specific packagesPackage overview →