Documentation
¶
Overview ¶
Package paths resolves the six per-app directories of contract.md section 9.3 on Linux and macOS. Resolution for each: the app's own variable (<APP>_CONFIG_DIR and so on), then the XDG variable, then the platform default. The package does not create the directories.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestEnv ¶
TestEnv returns the variables that put every directory of an app under dir, as NAME=value strings for exec.Cmd.Env or t.Setenv: <PREFIX>_CONFIG_DIR=<dir>/config, _DATA_DIR=<dir>/data, _STATE_DIR=<dir>/state, _LOGS_DIR=<dir>/logs, _CACHE_DIR=<dir>/cache, _RUNTIME_DIR=<dir>/run, plus LOG_OUTPUT=stderr so the run writes no log file. prefix is without the trailing underscore ("MYAPP"). It does not clear what the parent environment carries: an inherited <PREFIX>_LOG_OUTPUT wins over LOG_OUTPUT, and OTEL_* and TRACEPARENT would send the run's spans and trace to the real agent; a harness that builds a child environment strips those first.
Types ¶
type Option ¶
type Option func(*resolver)
Option changes how For resolves.
func Prefix ¶
Prefix sets the environment prefix without its trailing underscore ("MYAPP"), the form identity.Prefix takes, when it differs from the one derived from the app name: paths.For(id.Name, paths.Prefix(id.Prefix)). Empty keeps the derived prefix. A prefix with a trailing underscore is a programming error and panics, so "MYAPP_" cannot read MYAPP__CONFIG_DIR silently.
type Paths ¶
type Paths struct {
// Config holds settings and secrets; it moves with the user to a new machine.
Config string
// Data holds what the app cannot regenerate; it moves with the user.
Data string
// State holds what the app rebuilds over time; it stays on the machine.
State string
// Logs holds the log files of contract.md section 5.
Logs string
// Cache holds what the app can refetch.
Cache string
// Runtime holds sockets, pid and lock files; cleared at logout or reboot.
Runtime string
}
Paths holds the six directories of one app.