Skip to main content

Prerequisites

Before installing Salt, ensure you have:
Salt requires Go 1.22 or later. Check your version:
go version
If you need to install or upgrade Go, visit go.dev/doc/install.
Your project should be initialized as a Go module:
go mod init github.com/yourusername/yourproject

Install Salt

Add Salt to your project using go get:
go get github.com/raystack/salt
This command downloads Salt and adds it to your go.mod file.
Salt uses Go modules for dependency management. The go get command automatically resolves and installs all required dependencies.

Verify installation

Verify that Salt was installed correctly:
go mod tidy
go list -m github.com/raystack/salt
You should see the Salt module version printed:
github.com/raystack/salt v0.1.0

Import packages

Once installed, you can import any Salt package in your Go code:
package main

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

Available packages

Salt provides the following packages:
import (
    "github.com/raystack/salt/config"     // Configuration management
    "github.com/raystack/salt/log"        // Structured logging
    "github.com/raystack/salt/utils"      // General utilities
)

Modular installation

Salt’s modular design means you only download dependencies for packages you actually import. If you only use the config and log packages, dependencies for other packages won’t be pulled into your project.

Update Salt

To update to the latest version of Salt:
go get -u github.com/raystack/salt
go mod tidy

Version pinning

To use a specific version of Salt, specify the version tag:
go get github.com/raystack/[email protected]
You can also use commit hashes or branch names:
go get github.com/raystack/salt@main
go get github.com/raystack/salt@abc123

Troubleshooting

If you see a “module not found” error:
  1. Ensure you have network access to GitHub
  2. Check that your GOPRIVATE environment variable is configured correctly if using private modules
  3. Run go clean -modcache to clear the module cache
  4. Try again with go get github.com/raystack/salt
If you encounter version conflicts with dependencies:
  1. Run go mod tidy to clean up your dependencies
  2. Check your go.mod file for conflicting versions
  3. Use go mod graph to visualize the dependency tree
  4. Consider updating other dependencies: go get -u ./...
If imports aren’t resolving:
  1. Run go mod download to download all dependencies
  2. Restart your editor/IDE to refresh the Go module cache
  3. Verify the import path matches the package name exactly

Next steps

Quickstart guide

Now that Salt is installed, follow the quickstart guide to build your first application with config loading and logging.

Build docs developers (and LLMs) love