gookit / config

📝 Go configuration manage(load,get,set,export). support JSON, YAML, TOML, Properties, INI, HCL, ENV and Flags. Multi file load, data override merge, parse ENV var. Go应用配置加载管理,支持多种格式,多文件加载,远程文件加载,支持数据合并,解析环境变量名

Home Page:https://pkg.go.dev/github.com/gookit/config/v2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support default env prefix

vipcxj opened this issue · comments

For example:

	type Child struct {
		Name string `default:"${ NAME | child-name }"`
	}
	type App struct {
		Name   string `default:"${ APP_NAME | my-app }"`
		Env    string `default:"${ APP_ENV | dev}"`
		Debug  bool   `default:"${ APP_DEBUG | false}"`
		Child1 Child  `default:""`
		Child2 Child  `default:"" defaultenvprefix:"APP_CHILD_"`
	}

App.Child1 will use env NAME as its default value, and App.Child2 will use APP_CHILD_NAME as its default value.
This feature completely decouples the Child from the App.
I will make a pr for it.