aconfig:简单,有用且自以为是的配置加载程序

时间:2024-03-19 19:16:10
【文件属性】:

文件名称:aconfig:简单,有用且自以为是的配置加载程序

文件大小:28KB

文件格式:ZIP

更新时间:2024-03-19 19:16:10

config go golang command-line configuration

配置文件 简单,有用且自以为是的配置加载程序。 基本原理 关于Go中的配置加载,有很多解决方案。 我一直在寻找一个尽可能简单,易于使用和理解的装载机。 目标是从4个位置加载配置:默认值(在代码中),文件,环境变量,命令行标志。 该库可用于所有这些资源。 特征 简单的API。 干净且经过测试的代码。 自动字段映射。 支持不同的来源: 代码中的默认值 文件(JSON,YAML,TOML,DotENV,HCL) 环境变量 命令行标志 无依赖关系(文件解析器是可选的)。 能够遍历配置字段。 安装 Go版本1.14+ go get github.com/cristalhq/aconfig 例子 type MyConfig struct { Port int `default:"1111" usage:"just give a number"` Auth struct { Us


【文件预览】:
aconfig-main
----utils.go(3KB)
----go.mod(45B)
----aconfigdotenv()
--------dotenv_test.go(2KB)
--------go.mod(143B)
--------go.sum(521B)
--------dotenv.go(548B)
----example_test.go(4KB)
----.github()
--------workflows()
----testdata()
--------unknown_fields.json(43B)
--------config1.json(39B)
--------unknown.ext(30B)
--------config3.json(40B)
--------config.json(165B)
--------config2.json(23B)
--------example_config.json(89B)
--------bad_config.json(9B)
----aconfig_test.go(19KB)
----testfile.json(298B)
----LICENSE(1KB)
----doc.go(739B)
----aconfigtoml()
--------go.mod(143B)
--------go.sum(348B)
--------toml.go(545B)
--------toml_test.go(2KB)
----reflection.go(7KB)
----README.md(3KB)
----aconfig.go(9KB)
----aconfighcl()
--------go.mod(140B)
--------go.sum(515B)
--------hcl_test.go(2KB)
--------hcl.go(602B)
----aconfigyaml()
--------go.mod(133B)
--------go.sum(537B)
--------yaml_test.go(2KB)
--------yaml.go(537B)
----utils_test.go(810B)

网友评论