config

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package config implements load/save of Coggo's TOML configuration file.

The config file is optional: Load returns Default() when the file is missing. Defaults are filled in for any zero-valued fields after parse, so partial config files behave the same as empty ones for the unset fields.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataDir

func DataDir(c *Config) string

DataDir returns the expanded data directory.

func DefaultPath

func DefaultPath() string

DefaultPath returns the preferred config-file location. XDG-compliant (~/.config/coggo/config.toml) with a ~/.coggo/config.toml fallback if XDG can't be resolved.

func ExpandPath

func ExpandPath(p string) string

ExpandPath expands a leading "~" in p to the current user's home directory.

func ResolvedDBPath

func ResolvedDBPath(c *Config) string

ResolvedDBPath returns the SQLite database path inside the data dir.

func Save

func Save(path string, c *Config) error

Save writes c to path atomically (tmp + rename) with mode 0644. Parent directories are created if missing.

Types

type Config

type Config struct {
	Server    ServerConfig    `toml:"server"`
	Storage   StorageConfig   `toml:"storage"`
	Embedding EmbeddingConfig `toml:"embedding"`
	Tailscale TailscaleConfig `toml:"tailscale"`
	Logging   LoggingConfig   `toml:"logging"`
}

Config is the on-disk configuration. See spec §9.2.

func Default

func Default() *Config

Default returns a Config populated with the v0.1 defaults.

func Load

func Load(path string) (*Config, error)

Load reads a Config from disk. If the file is missing, Default() is returned with no error. Defaults are applied to any zero-valued fields.

type EmbeddingConfig

type EmbeddingConfig struct {
	Provider string `toml:"provider"`
	Model    string `toml:"model"`
}

EmbeddingConfig holds the embedding provider settings. The API key is sourced from the COGGO_EMBEDDING_API_KEY environment variable, never the config file.

type LoggingConfig

type LoggingConfig struct {
	Level string `toml:"level"`
}

LoggingConfig holds the slog level.

type ServerConfig

type ServerConfig struct {
	ListenAddress string `toml:"listen_address"`
	DataDir       string `toml:"data_dir"`
}

ServerConfig holds the listen address and data directory.

type StorageConfig

type StorageConfig struct {
	Backend            string `toml:"backend"`
	EmbeddingDimension int    `toml:"embedding_dimension"`
}

StorageConfig holds the storage backend selection and embedding dimension.

type TailscaleConfig

type TailscaleConfig struct {
	Enabled       bool `toml:"enabled"`
	FunnelEnabled bool `toml:"funnel_enabled"`
}

TailscaleConfig holds the Tailscale integration toggles.

Jump to

Keyboard shortcuts

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