Skip to main content
Salt is a modular Go library providing essential building blocks for backend services. Each package is designed to be independent, lightweight, and production-ready.

Package Categories

Core Infrastructure

Config

Flexible configuration management with support for files, environment variables, and command-line flags

Database

Database connection management with connection pooling and migrations

Logging

Structured logging with multiple backend implementations

Telemetry

OpenTelemetry integration for metrics and distributed tracing

CLI Development

Commander

Enhanced Cobra command management with topics, hooks, and reference generation

Printer

Terminal output utilities including tables, spinners, and progress bars

Prompter

Interactive user input with selections, confirmations, and text input

Authentication & Security

OIDC

OpenID Connect authentication with PKCE support

Audit

Audit logging for tracking user actions and system events

Server Utilities

Mux

Multiplexed server management for HTTP and gRPC

SPA

Single-page application serving utilities

Data Processing

JSON Diff

Intelligent JSON comparison and change tracking

RQL

REST Query Language parser for advanced filtering and sorting

Utils

General utilities including gRPC status helpers

Installation

Install Salt packages using Go modules:
go get github.com/raystack/salt
Or install specific subpackages:
go get github.com/raystack/salt/config
go get github.com/raystack/salt/log
go get github.com/raystack/salt/db

Design Principles

Each package is independently usable. Import only what you need without carrying unnecessary dependencies.
All packages are battle-tested in production environments and follow Go best practices.
Carefully curated dependencies to keep your binary size small and maintenance burden low.
Designed with testing in mind, including mock implementations and test utilities.

Quick Start Example

Here’s a complete example combining multiple Salt packages:
package main

import (
    "context"
    "github.com/raystack/salt/config"
    "github.com/raystack/salt/db"
    "github.com/raystack/salt/log"
    "github.com/raystack/salt/telemetry"
)

type Config struct {
    Database  db.Config         `mapstructure:"database"`
    Log       LogConfig         `mapstructure:"log"`
    Telemetry telemetry.Config  `mapstructure:"telemetry"`
}

type LogConfig struct {
    Level string `mapstructure:"level" default:"info"`
}

func main() {
    // Load configuration
    loader := config.NewLoader(
        config.WithFile("config.yaml"),
        config.WithEnvPrefix("APP"),
    )
    
    cfg := &Config{}
    if err := loader.Load(cfg); err != nil {
        panic(err)
    }
    
    // Initialize logger
    logger := log.NewLogrus(
        log.LogrusWithLevel(cfg.Log.Level),
    )
    
    // Initialize telemetry
    ctx := context.Background()
    cleanup, err := telemetry.Init(ctx, cfg.Telemetry, logger)
    if err != nil {
        logger.Fatal("failed to initialize telemetry", "error", err)
    }
    defer cleanup()
    
    // Connect to database
    dbClient, err := db.New(cfg.Database)
    if err != nil {
        logger.Fatal("failed to connect to database", "error", err)
    }
    defer dbClient.Close()
    
    logger.Info("application started successfully")
}

Package Dependencies

Salt uses the following major dependencies:
  • Configuration: Viper, Cobra, pflags
  • Database: sqlx, golang-migrate
  • Logging: logrus
  • Telemetry: OpenTelemetry
  • CLI: Cobra, survey, tablewriter
  • Auth: golang.org/x/oauth2

Getting Help

GitHub Issues

Report bugs or request features

Examples

Browse example code and usage patterns