-
Notifications
You must be signed in to change notification settings - Fork 60
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
base: master
Are you sure you want to change the base?
增加环境变量的Key转为小写的存储和查询 #159
Conversation
如环境变量为:CONFIG_TEST,则可以通过config.test,进行查询
请描述user story |
在Linux的习惯里,环境变量均为大写,如SERVER_ADDR,而配置文件中一般为小写,如:server.addr,为了能够通过archaius来屏蔽配置环境变量与其他配置源在读配置上的差异性,希望把环境变量的每个字段都换成小写,这样就可以用同一种key的格式来获取配置,并兼顾环境变量和配置文件,这个在UnmarshalConfig方式里更能体现 |
@@ -0,0 +1,10 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个文件可以放到test目录下
在这个位置补充下使用文档 Line 111 in 2b7c9e9
|
@@ -99,7 +99,7 @@ func Init(opts ...Option) error { | |||
} | |||
} | |||
if o.UseENVSource { | |||
envSource := env.NewEnvConfigurationSource() | |||
envSource := env.NewEnvConfigurationSource(o.EnvKeyLowerCases) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些测试文件都放到test目录,或者别传上来,或者用go的新特性,tmpdir来写文件
如环境变量为:CONFIG_TEST,则可以通过config.test,进行查询