Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加环境变量的Key转为小写的存储和查询 #159

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ichiro999
Copy link
Contributor

如环境变量为:CONFIG_TEST,则可以通过config.test,进行查询

如环境变量为:CONFIG_TEST,则可以通过config.test,进行查询
@tianxiaoliang
Copy link
Member

请描述user story

@ichiro999
Copy link
Contributor Author

请描述user story

在Linux的习惯里,环境变量均为大写,如SERVER_ADDR,而配置文件中一般为小写,如:server.addr,为了能够通过archaius来屏蔽配置环境变量与其他配置源在读配置上的差异性,希望把环境变量的每个字段都换成小写,这样就可以用同一种key的格式来获取配置,并兼顾环境变量和配置文件,这个在UnmarshalConfig方式里更能体现

@@ -0,0 +1,10 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件可以放到test目录下

@tianxiaoliang
Copy link
Member

tianxiaoliang commented Apr 7, 2022

请描述user story

在Linux的习惯里,环境变量均为大写,如SERVER_ADDR,而配置文件中一般为小写,如:server.addr,为了能够通过archaius来屏蔽配置环境变量与其他配置源在读配置上的差异性,希望把环境变量的每个字段都换成小写,这样就可以用同一种key的格式来获取配置,并兼顾环境变量和配置文件,这个在UnmarshalConfig方式里更能体现

在这个位置补充下使用文档

if you want to read some.config from env

@@ -99,7 +99,7 @@ func Init(opts ...Option) error {
}
}
if o.UseENVSource {
envSource := env.NewEnvConfigurationSource()
envSource := env.NewEnvConfigurationSource(o.EnvKeyLowerCases)
Copy link
Member

@tianxiaoliang tianxiaoliang Apr 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不建议改变现有API了,我担心已经有人调用了,写新函数EnableLowerCase吧

@@ -0,0 +1,3 @@

age: 14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些测试文件都放到test目录,或者别传上来,或者用go的新特性,tmpdir来写文件

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants