On this page
API reference for the config package — TOML configuration management, directory initialization, and default settings for saferm.
#internal/config
#internal/config
Package config manages saferm's TOML configuration and directory initialization. Configuration is loaded from ~/.saferm/config.toml with sensible defaults when the file is absent.
#Config
type Config structConfig holds saferm configuration, loaded from TOML.
#BaseDir
func BaseDir() stringBaseDir returns the saferm base directory. If SAFERM_HOME is set, its value is used as-is (expected to be an absolute path). Otherwise falls back to ~/.saferm/.
#DefaultConfig
func DefaultConfig() *ConfigDefaultConfig returns a Config with all defaults filled in.
#Load
func Load() (*Config, error)Load reads the config file from the default location (~/.saferm/config.toml) and returns a Config with defaults applied. If the file doesn't exist, returns the default config without error.
#LoadFrom
func LoadFrom(path string) (*Config, error)LoadFrom reads config from the specified path. If the file doesn't exist, returns the default config without error. If it exists but is malformed, returns an error.
#EnsureDirectories
func EnsureDirectories(cfg *Config) errorEnsureDirectories creates the archive dir, db dir (parent of DBPath), and base dir if they don't exist. Uses 0700 permissions.