config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config loads and validates the cosql TOML config file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns ~/.config/cosql/config.toml.

Types

type Config

type Config struct {
	DefaultDB string              `toml:"default_db"`
	DB        map[string]Database `toml:"db"`
}

Config is the top-level TOML config.

func Load

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

Load reads and validates the config at path. An empty path resolves to DefaultPath. The file must have mode 0600 (no group/other bits).

func (*Config) Aliases

func (c *Config) Aliases() []string

Aliases returns a sorted list of configured db aliases.

func (*Config) Get

func (c *Config) Get(alias string) (Database, error)

Get returns the database for an alias. If alias is empty, DefaultDB is used.

type Database

type Database struct {
	Driver string `toml:"driver"` // "postgres" or "mysql"
	DSN    string `toml:"dsn"`
	Notes  string `toml:"notes"`
}

Database describes a single db alias.

Jump to

Keyboard shortcuts

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