datadir

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package datadir decides where the server keeps its database when --db is not given.

A database that silently lands in whatever folder the program was started from loses its history as soon as someone starts it from elsewhere. So, in order:

  1. --db, when given;
  2. the CIPHERHORIZON_DB environment variable;
  3. a cipherhorizon.db already in the working directory (where versions before 0.1.0 put it), so an upgrade never appears to lose data;
  4. the operating system's per-user data folder: Windows %LOCALAPPDATA%\CipherHorizon\cipherhorizon.db macOS ~/Library/Application Support/CipherHorizon/cipherhorizon.db Linux $XDG_DATA_HOME/cipherhorizon/cipherhorizon.db (~/.local/share/cipherhorizon/...)

Services and containers name the path explicitly (/var/lib/cipherhorizon, /data, %ProgramData%\CipherHorizon), so they never depend on this.

Index

Constants

View Source
const EnvVar = "CIPHERHORIZON_DB"

EnvVar names the environment variable that overrides the default location.

View Source
const File = "cipherhorizon.db"

File is the database's file name.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath is the per-user location, without creating anything (for help text).

Types

type Source

type Source int

Source says which rule chose the path.

const (
	FromFlag Source = iota
	FromEnv
	FromWorkingDir
	FromDefault
)

The rules, in the order they are tried.

func Resolve

func Resolve(flagValue string) (string, Source, error)

Resolve returns the database path for a --db value (empty when the flag was not given). For FromDefault it also creates the folder, readable by its owner only.

Jump to

Keyboard shortcuts

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