saferm v0.2.0 /internal/config
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

Go go
type Config struct

Config holds saferm configuration, loaded from TOML.

#BaseDir

Go go
func BaseDir() string

BaseDir 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

Go go
func DefaultConfig() *Config

DefaultConfig returns a Config with all defaults filled in.

#Load

Go go
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

Go go
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

Go go
func EnsureDirectories(cfg *Config) error

EnsureDirectories creates the archive dir, db dir (parent of DBPath), and base dir if they don't exist. Uses 0700 permissions.