Documentation
¶
Overview ¶
Package config 负责加载与解析 dbm 的 YAML 配置。
配置文件查找顺序(首个命中即用):
- --config 指定的路径
- 当前目录:./.dbm-cli.yaml → ./.dbm-cli.yml → ./dbm-cli.yaml → ./dbm-cli.yml
- 用户主目录:~/.dbm-cli.yaml → ~/.dbm-cli.yml
- $XDG_CONFIG_HOME/dbm-cli/config.yaml(或 ~/.config/dbm-cli/config.yaml)
配置内支持 ${ENV_VAR} 占位,加载时从环境变量展开,避免在文件里明文存放密码。
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("config: no dbm-cli config file found (create ./.dbm-cli.yaml or ~/.dbm-cli.yaml, or set --config)")
ErrNotFound 表示未找到任何配置文件。
Functions ¶
func DefaultSearchPaths ¶
func DefaultSearchPaths() []string
DefaultSearchPaths 返回配置文件的查找路径(按优先级从高到低), 但不包含显式 --config 指定的路径(该路径在 Load 中单独处理)。 注意:这里返回的都是「候选」,首个存在者生效。
规范的配置文件名是 .dbm-cli.yaml(dotfile 形式,cwd 与 home 一致); 此外也兼容不带点的 dbm-cli.yaml/.yml 与 XDG 标准位置。
Types ¶
type File ¶
type File struct {
Default string `yaml:"default"` // 默认数据源名
Datasources map[string]*driver.DatasourceConfig `yaml:"datasources"` // 数据源集合
}
File 是 dbm.yaml 的顶层结构。
type ValidationError ¶
ValidationError 表示配置校验失败。
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Click to show internal directories.
Click to hide internal directories.