config

package
v0.0.0-...-8d28fdc Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigExists

func ConfigExists() bool

ConfigExists returns true if the config file exists.

func GetConfigPath

func GetConfigPath() (string, error)

GetConfigPath returns the path to the belt configuration file.

Types

type AppConfig

type AppConfig struct {
	Name    string `koanf:"name"`
	Version string `koanf:"version"`
	Debug   bool   `koanf:"debug"`
}

AppConfig holds application-specific settings.

type Config

type Config struct {
	App     AppConfig     `koanf:"app"`
	Output  OutputConfig  `koanf:"output"`
	Logging LoggingConfig `koanf:"logging"`
	Crypt   CryptConfig   `koanf:"crypt"`
	DNS     DNSConfig     `koanf:"dns"`
}

Config holds the application configuration.

func Get

func Get() *Config

Get returns the loaded configuration.

func Load

func Load() (*Config, error)

Load loads configuration from multiple sources in order of precedence: 1. Environment variables (BELT_*) 2. Config files (belt.yaml, belt.json) 3. Default values.

type CryptConfig

type CryptConfig struct {
	Env    string `koanf:"env"`    // Environment variable name for encryption key
	Key    string `koanf:"key"`    // Base58-encoded encryption key
	Warned bool   `koanf:"warned"` // Whether user has been warned about key backup
}

CryptConfig holds cryptography settings.

func (*CryptConfig) GetKey

func (c *CryptConfig) GetKey() string

GetKey returns the encryption key, checking environment variable first.

type DNSConfig

type DNSConfig struct {
	Server string `koanf:"server"` // Default DNS server
	Root   bool   `koanf:"root"`   // Whether to use root servers by default
}

DNSConfig holds DNS settings.

type LoggingConfig

type LoggingConfig struct {
	Level  string `koanf:"level"`
	Format string `koanf:"format"`
}

LoggingConfig holds logging settings.

type OutputConfig

type OutputConfig struct {
	Format string `koanf:"format"`
	Color  bool   `koanf:"color"`
	Quiet  bool   `koanf:"quiet"`
	Silent bool   `koanf:"silent"`
}

OutputConfig holds output formatting settings.

Jump to

Keyboard shortcuts

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